Using Go in Jupyter Notebook

From time to time I want to use Jupyter with Go code elements instead of Python. Luckily, this is possible thanks to the Go kernel provided by the gophernotes project. Under the hood this uses the plugin system introduced with Go 1.8 and then later extended in Go 1.10. This has the consequence that some functionality is only available on Linux and macOS but not on Windows.

In order to use gophernotes as kernel for Jupyter-Notebook you have to run the following steps (asuming that you’re on Linux or macOS):

# We want to install the binary so we need to deactivate Go Modules
# for now:
$ export GO111MODULE=off
$ go get -u

# For macOS
$ mkdir -p $HOME/Library/Jupyter/kernels/gophernotes
$ cp $GOPATH/src/* \

# For Linux
$ mkdir -p $HOME/.local/share/jupyter/kernels/gophernotes
$ cp $GOPATH/src/* \

Once that’s done, start a new jupyter-notebook instance. In the “New” menu you should now see a “Go” entry which will use the gophernotes kernel.