My first experience with go!
In my effort to learn a new language I started to checkout
Rust both for
some days and do a bit in both to decide which one to choose for a deeper experience.
I worked a lot with Java later with NodeJS but both have some problems
for me. Java is not after my liking, while NodeJS is great for fast prototyping but
get problems if the project grows really big.
So in this article I describe the findings of
Go as an notebook for myself.
This is done really easy under Linux:
# download curl -O https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz # install sudo tar -C /usr/local -xzf go1.8.1.linux-amd64.tar.gz rm go1.8.1.linux-amd64.tar.gz # set path to go and compiled programs echo "export GOPATH=$HOME/go" >> ~/.bashrc echo "export GOPATH=$HOME/go" >> ~/.profile echo "export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin" >> ~/.bashrc echo "export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin" >> ~/.profile export GOPATH=$HOME/go export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin # install additional helpers go get -u github.com/nsf/gocode go get -u github.com/golang/lint/golint
Other installation methods also exist see the Project Site.
You will find all the go related stuff below a
go folder in your home directory.
To dive into I worked through the following resources:
The go workspace (
~/go under Linux) contains the following directories:
src/ # sources github.com/alinex/go-learn # package source .git/ # version control system ... pkg/ # downloaded packages bin/ # executable commands
At first I use the
Atom editor with the following plugins:
No need for a style guide here because formatting is done by
on it's own on saving.
The above installers
go-signature-statusbar will you show a reference using
Alt-D with the cursor on a specific symbol.
All the possible tools are combined in the go cli tool:
go build # check if it can be compiled go install # to build and make a runnable command go test # run unit tests <name> # to directly run it, because you have it in your path go get <path> # fetch and install
To show your documentation in the browser start the
godoc -http=:6060 & # to start it in the background xdg-open http://localhost:6060/pkg/ # to open the package list in the browser
And then go in your browser to Learning Go.