Install

Download: https://golang.org/dl/

Jupyter

https://github.com/gopherds/gophernotes

docker pull dwhitena/gophernotes:latest
docker run --name gophernotes --net host -d dwhitena/gophernotes:latest

System default

In [35]:
dpkg -l golang-{go,src} | grep ^ii
ii  golang-src                         2:1.0.2-1.1                               amd64        Go programming language compiler - source files

GOROOT - for program

In [73]:
echo export GOROOT=/root/go  >> $HOME/.profile
echo export PATH=$PATH:$GOROOT/bin  >> $HOME/.profile
source $HOME/.profile
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/anaconda3/bin/:/root/go/bin
In [74]:
go env GOROOT
which go
go version
/root/go
/root/go/bin/go
go version go1.6.3 linux/amd64

GOPATH - for data

In [75]:
echo export GOPATH=$HOME/go_work:$HOME/Dropbox/go >> $HOME/.profile
source $HOME/.profile

In [77]:
cat $HOME/.profile | tail -n -4
echo ''
echo $GOPATH
mesg n
export GOROOT=/root/go
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/anaconda3/bin/:/root/go/bin
export GOPATH=/root/go_work:/root/Dropbox/go

/root/go_work:/root/Dropbox/go

Coding

In [92]:
string=$GOPATH
set -f                      # avoid globbing (expansion of *).
array=(${string//:/ })
for i in "${!array[@]}"
do
    echo "${array[i]}"
    ls  -l "${array[i]}"
done
/root/go_work
total 12
drwxr-xr-x 2 root root 4096 Aug 10 15:31 bin
drwxr-xr-x 3 root root 4096 Aug 10 14:55 pkg
drwxr-xr-x 4 root root 4096 Aug 10 14:55 src
/root/Dropbox/go
total 8
drwxr-xr-x 3 root root 4096 Aug 10 16:01 src
In [93]:
mkdir -p /root/Dropbox/go/src/github.com/fzinfz/hello

In [ ]:
go install github.com/fzinfz/hello
In [ ]: