Walk is a "Windows Application Library Kit" for the Go Programming Language.
Its primarily useful for Desktop GUI development, but there is some more stuff.
Make sure you have a working Go installation. See Getting Started
Go 1.7.x
doesn't work with walk anymore, Make sure you use Go 1.8.x
or later.
Now run go get github.com/lxn/walk
The preferred way to create GUIs with Walk is to use its declarative sub package, as illustrated in this small example:
package main
import (
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
"strings"
)
func main() {
var inTE, outTE *walk.TextEdit
MainWindow{
Title: "SCREAMO",
MinSize: Size{600, 400},
Layout: VBox{},
Children: []Widget{
HSplitter{
Children: []Widget{
TextEdit{AssignTo: &inTE},
TextEdit{AssignTo: &outTE, ReadOnly: true},
},
},
PushButton{
Text: "SCREAM",
OnClicked: func() {
outTE.SetText(strings.ToUpper(inTE.Text()))
},
},
},
}.Run()
}
In the directory containing test.go
run
go build
To get rid of the cmd window, instead run
go build -ldflags="-H windowsgui"
test.exe
There are some examples that should get you started.
By default Go uses os threads with small stack sizes of 128KB. If your walk app crashes, it may be due to a stack overflow. Until a better solution is found, you can work around this by adding
import _ "runtime/cgo"
somewhere in your program. If you don't have gcc
installed and on your PATH
,
you can alternatively add -linkmode internal
to the -ldflags
of your go build
command like so:
go build -ldflags="-H windowsgui -linkmode internal"