Ian Fabs
Posted on November 5, 2019
Today I decided I wanted to write something in go using Microsoft's new Visual Studio Online. I won't be going over how to setup this up, because Azure can be a pain in the rear and because it deserves it's own article.
To get started, open up the environment you want to use.
Step One: Installation
First, we are going to download the latest version of Go:
vsonline:~/workspace$ wget https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz
Once you have that downloaded, go ahead and extract it:
vsonline:~/workspace$ tar -xvf go1.13.4.linux-amd64.tar.gz
Now that you have extracted the go
folder, we are going to move it to /usr/local
vsonline:~/workspace$ sudo mv go /usr/local
Step Two: Setup GOROOT
and GOPATH
We are going to two create two new environment variables, and then modify another.
In your terminal, enter the following:
vsonline:~/workspace$ vim ~/.bashrc
This will open up your bash profile in a command-line editor called Vim. For those who don't know how to use vim, or are scared of it, don't worry. I will guide you keypress by keypress.
Vim Steps:
- hold
Shift
+G
and release - press
o
- press
enter
(you are now in editing mode) add the following lines where your cursor is:
export GOROOT=/usr/local/go
export GOPATH=$HOME/workspace
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
- press
Esc
(Escape
) - hold
Shift
and double tap theZ
key
You have successfully escaped Vim, and saved your file. You should now be back at your terminal prompt.
Enter the following command:
vsonline:~/workspace$ source ~/.profile
Vous voilà!
Step Three: Make sure it works
The last step, is to make sure everything we did took hold.
vsonline:~/workspace$ go version
go version go1.13.4 linux/amd64
vsonline:~/workspace$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/vsonline/.cache/go-build"
GOENV="/home/vsonline/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/vsonline/workspace"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build921856996=/tmp/go-build -gno-record-gcc-switches"
If your output looks like mine, you're good to go! You've successfully installed Golang in VSOnline :-)
Happy Hacking!
Posted on November 5, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.