This is a creation in Article, where the information may have evolved or changed. As a win enthusiasts, I have to say, usually after learning a new language I will be very eager to make a pop-up window to test the language in the win form effect, here not much to say, first on the code.
Package Mainimport ("Github.com/lxn/go-winapi" "Syscall" "StrConv") Func _text (_str string) *uint16{return syscall. Stringtoutf16ptr (_STR)}func _tostring (_n int32) String{return StrConv. Itoa (int (_n))}func main () {var hwnd winapi. Hwndcxscreen: = WINAPI. GetSystemMetrics (WINAPI. Sm_cxscreen) Cyscreen: = WinAPI. GetSystemMetrics (WINAPI. Sm_cyscreen) WINAPI. MessageBox (Hwnd,_text ("Hello everyone, my screen width is:" + _tostring (cxscreen) + "height is:" + _tostring (cyscreen)), _text ("Golang window Test"), WinAPI. MB_OK)}
Remember the format mentioned before, it is no longer described here, focus on my writing this effect encountered problems and solutions
Import ("Github.com/lxn/go-winapi" "Syscall" "StrConv")
When using import, here is the introduction of the GO-WINAPI package, it is obvious that the default installation go in case this package is not, so we need to get this package, get the way, you can directly use go get github.com/lxn/ Go-winapi gets this package and installs it automatically for you under the GO environment you configured, but the installation might prompt you for a bug that git can't find, the workaround is to install this Git program, not here, because I'm useless, I used another way to open this URL directly Github.com/lxn/go-winapi then download the compressed package, and then come back to your own Src/pkg/github.com/lxn/go-weinapi directory to extract it, of course, not necessarily this directory, if you change this directory, Please import the path you have changed when importing. What's more, it's worth noting that when you need a function in a package, but don't know what to do or how to use it, please go directly to this package to see, there are corresponding files, a little bit of English can be.