Semi-official: Https://godoc.org/golang.org/x/exp/shiny
Mr Wang
Links: https://www.zhihu.com/question/22483719/answer/21753337
Source: Know
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.
I've been using Andlabs/ui since the end of 2014. GitHub develops GUI programs. This library supports multiple operating systems, including Linux and MacOSX. and the API and program structure make full use of Go's signature syntax: Lambda, goroutine, and channels. Look at the code of this library, fully aware that Go is actually better than Objective-c, Java, C + +, Python, TCL/TK, MATLAB are more suitable for the development of GUI program-Concise program, rich function, efficient execution. The only regret is that it only supports desktop operating systems. I asked if the author could support mobile development (supported ios? Issue #64 · Andlabs/ui GitHub), the author finds that the mobile GUI program differs too much from the desktop GUI program and should use another library to support the development of the mobile GUI.
The following answers come from my blog: GUI programming Using Go; I want to collect and summarize some information.
The go language has an interesting topic of how to write GUI programs in the Go language. Because go standard packages is not used to write GUI program, so many people ask, can have a standard GUI package?
In June 2013, there was an interview with Go authors. Some of them also asked the above questions. Rob Pike directly mentions the Newsqueak language he designed when he was young, a language designed to write GUI programs. Andrew Gerrand quickly pulled the conversation back and introduced several of the better third-party GUI packages he had seen. The reduced version of this interview can be found on the Go homepage:/httpblog.golang.org/a-conversation-with-the-go-team
I have used a few of the more convenient GUI toolkit, including GTK and Qt. Based on this experience, I agree with Rob Pike's vision of the go language in GUI programming:
Go supports memory garbage collection. This makes it easy to manage the memory consumption of the widgets. People who have used GTK should all be forced to understand the floating reference mechanism based on C design? The GOTK3 author's blog specifically describes how to redesign the GUI widgets memory management mechanism based on the go language. Worth reading, very inspiring!
Go concurrency should be able to conveniently let the GUI not be dragged down by the background processing, maintain the smooth interface reaction. Do you remember the BeOS (Apple was supposed to have bought it if he hadn't stepped in) and finally bought next? An important feature of this is the use of multithreading technology to ensure that the GUI is always responsive.
Although Andrew Gerrand at that time the author of the example Go.uik had turned off the project and claimed that "if you open it again, be sure to rewrite it":
This project is closed. If I Begin Again, it'll be is from scratch and using the lessons learned while writing Go.uik. Of course, if I begin again it'll still be called Go.uik.
But other projects abound. I tried go-qt5 last week on my imac (Mavericks), which is a QT 5 go language binding. Today, I just tried gotk3, a GTK binding that was written entirely with Go memory management (idiomatic). It feels good. Because these two projects are in rapid evolution, the usage and actual operations described on their home page are slightly different. Here's a list of my actions.
Go-qt5
The tutorial on the homepage is not fully in my environment, and my summary is here. Or simply record the operation flow as follows:
Install with Homebrew 5.2:
brew update && brew doctor && brew install qt5
This will remind you that "most people in the world are now using QT4, or not so aggressively with Qt5?" "(Homebrew is really humane.) But I'm sorry, QT4 does not support the latest version of OS X Mavericks.
Check out the GO-QT5 code:
mkdir -p /home/you/go-qt5 export GOPATH=/home/you/go-qt5 go get github.com/salviati/go-qt5
Build GO-QT5
Basically can follow the go-qt5 of the Readme to operate. There are a few points to note: Because homebrew does not create symbolic links under/usr/local/bin that point to QT 5, you may need to use the full path name when you call Qmake:/usr/local/cellar/qt5/5.2.0/ Bin/qmake. In addition, when running your own QT program, remember to put the link library $gopath/src/github.com/salviati/go-qt5/lib/libgoqt5drv.1.0.0.dylib and your program in the same directory.
Gotk3
The installation and use on Mac OS X is basically based on this article, but there are two points to note:
If build GTK3, error cannot find-lpython2.7, you can tell Jhbuild Python's library by ldflags environment variable. Like what:
LDFLAGS=-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/ jhbuild build meta-gtk-osx-gtk3
Also, when compiling GOTK3, you do not need to start a new shell with the jhbuild shell, just set the environment variable:
export PKG_CONFIG_PATH=/Users/wangyi/gtk/inst/lib/pkgconfig:/Users/wangyi/gtk/inst/share/pkgconfig:/usr/lib/pkgconfig
Then you can download and compile the GOTK3 via go get.
go get github.com/conformal/gotk3/gtk
Https://github.com/go-qml/qml
Https://github.com/google/gxui
https://www.zhihu.com/question/22483719
The GUI scheme of the Go language, which can be bound to Qt and QML, also has the gxui of writing from scratch