Installing GTK+ and webkit development environment for Go (golang)

Process to get a working Go development environment for GTK+ and Webkit on Debian.

Install needed debian packages:

apt-get install golang git libwebkit2gtk-4.0-dev libjavascriptcoregtk-3.0-dev

Create a workspace for go development:

mkdir ~/go
export GOPATH=~/go

Note: putting the GOPATH export in .bashrc should work, but experience has shown it doesn’t. Verifying it is set (by .bashrc) and running a build results in errors about ‘$GOPATH not set.’ Running it manually solves this.

Clone source code for gotk3 and webkit: and move the resulting gotk3 folder into ~/go/src/ into ~/go/src/ into ~/go/src/

And, clone examples for gotk3 into ~/go/src/

Build and install each of these into this local directory structure:

cd ~/go/src/
go install ./gojs

This creates ~/go/pkg/linux-amd64/ Do likewise for gotk3 and go-webkit2.

The Go units tests can be run using (using webkit2 as an example):

cd ~/go/src/
go test ./webkit2

The code should build and you’ll get some indication that the test PASSED.

With this, the gotk3 examples can be built and run to test. I have webkit2 examples yet to do.

Go GTK applications are built just as any Go application. The Go package for the main .go file needs to be main, and the main function needs to be main().

Note that there can be many different branches, or even separate projects for the github projects. For example gotk3, conformal and gotk3 are completely different projects, even though they are both bindings for GTK in Go.