Go (Golang) for beginners


Because I might not be the only newbie in the Go world this year, I've decided to document here all the information I gathered.

Install Go

Go installation is pretty well documented on the  official Golang page but it can be summarized to:
  • Downloading the binary matching your OS and architecture from the golang download page
    wget https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz
  • Extracting the software (/usr/local/go seems to be the recommended location)
    tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz
  • Creating your Workspace
    Go workspace is the place where you put your source code and where the go packages/tools will be downloaded.
    mkdir $HOME/go
    In this directory, create a src subdirectory where you'll place all your code.
    mkdir $HOME/go/src
  • Setting the environment variables
    Setting  GOPATH (export GOPATH=$HOME/go) to point to your workspace.
    Then your path PATH (export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
    • For a system-wide configuration:
      in /etc/profile
    • For a per user configuration:
      in ~/.profile

Editor configuration

If you use vim as I do, you might want to use vim-go or vim-polyglot and read the vim-go tutorial.
But if it's not your case, your solution is probably on the page about the IDEs and editor plugins for Go.

So much more to explore

With this (basic) setup I'm now ready to go further 
  • Setting up Go in docker
  • Do some datascience
  • Unleashed goroutines/channels power
  • ...
But that will be in another post :-)

Resources

There are of course many more useful resources to start with.
But I hope the following ones will be as useful to you as they were to me.



Commentaires

Posts les plus consultés de ce blog

Change your Gogs admin password

JavaScript for Perl lovers.

What is the average salary for Perl programmers in 2020?