Go dev and usage - wiki

data_science
ubuntu
golang
Tags: #<Tag:0x00007f0cad75cc48> #<Tag:0x00007f0cad75c838> #<Tag:0x00007f0cad75c5b8>

#1

Go go get me...

Environment setup

Install Go from the PPA to get a recent build (Ubuntu 16 LTS)

sudo apt-get install git
sudo add-apt-repository ppa:gophers/archive
sudo apt-get update
sudo apt-get install golang-1.10-go # example

Proper .*rc varibales for the ENV (*nix)

Examples of errors:

package github.com/gopherdata/gophernotes: cannot download, $GOPATH not set. For more details see: 'go help gopath'

warning: GOPATH set to GOROOT (/home/marius/go) has no effect
package github.com/gopherdata/gophernotes: cannot download, $GOPATH must not be set to $GOROOT. For more details see: 'go help gopath'

Example of fixes:

[email protected]:~$ tail -n4 .bashrc
export PATH=$PATH:/usr/lib/go-1.10/bin/
#export GOROOT=$HOME/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin

And...

  • Ensure GOROOT is unset.
  • ~/go should exist

DataScience and Go

Get a Go kernel for nteract to create code-driven stories

Nteract {1} can be used with the Go runtime {2}.

sudo apt-get install libzmq3-dev
go get -u github.com/gopherdata/gophernotes
mkdir -p ~/.local/share/jupyter/kernels/gophernotes
cp $GOPATH/src/github.com/gopherdata/gophernotes/kernel/* ~/.local/share/jupyter/kernels/gophernotes

References

{1} Nteract is an app for Jupyter notebooks, which are popular for Python

{2} gophernotes adds the Go kernel