DEV Community

Cover image for Getting started with Go-Lang
David Mutebi
David Mutebi

Posted on

Getting started with Go-Lang

Been looking into go-lang this past month and decided to give it a go.
this is tutorial i will take you through the different steps i took to setup the go-lang development environment on my pc.

the first step I recommend is to use GVM, GVM is the Go Version Manager.
To install GVM type in the following command in your terminal.

`


bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

if you are using zsh instead of bash you can use the following command.


zsh < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

once installed you can later check the available commands it comes with by entering the following command in your terminal.

$ gvm

below are some of the few it will display on your screen.

`

$ gvm
Usage: gvm [command]

Description:
  GVM is the Go Version Manager

Commands:
  version    - print the gvm version number
  get        - gets the latest code (for debugging)
  use        - select a go version to use (--default to set permanently)
  diff       - view changes to Go root
  help       - display this usage text
  implode    - completely remove gvm
  install    - install go versions
  uninstall  - uninstall go versions
  cross      - install go cross compilers
  linkthis   - link this directory into GOPATH
  list       - list installed go versions
  listall    - list available versions
  alias      - manage go version aliases
  pkgset     - manage go packages sets
  pkgenv     - edit the environment for a package set
Enter fullscreen mode Exit fullscreen mode


Once gvm is installed, you can proceed to restart your terminal so it can get activated, since i was using bash i used the following command to restart my terminal.

$ exec bash -l

on restart, you can check the gvm version using the following command.

`


$ gvm version

Go Version Manager v1.0.22 installed
`

you can also set the environment variables using the following commands.

$ [[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"
$ export GOPATH=$HOME/go
$ export GOBIN=$GOPATH/bin
$ export PATH=${PATH}:$GOBIN:$GOROOT/bin
Enter fullscreen mode Exit fullscreen mode

this will set set your $GOROOT and $GOPATH environment variables.

you can restart your terminal again to proceed with the following steps smoothly.

You can proceed to install go using the following gvm command.
gvm install go1.17.5

At the time of this article was written that was the latest version go released. To check for other go version releases follow this link.

Once go is installed. you can use this command to check for the version installed and also verify the installation.

$ go version

Go as a programming language has a wide range of applicability, it was originally built for programs related to networking and infrastructure. It was intended to replace popular high-performance server-side languages like Java and C++. Today, Go is used for a variety of applications like cloud and server side applications, DevOps, command line tools and much more.

in future articles i will demonstrate how to create applications in go.

thanks for reading 😊

Top comments (4)

Collapse
 
jonasbn profile image
Jonas Brømsø

There is also a Go plugin for asdf, I have not tried it yet, I only recently learned about it via the comments on "The First Two Dev Tools Installed On My M1 Mac ", but it does look very interesting

Collapse
 
hamzaanis profile image
Hamza Anis

I didn't know that there was gvm.

Collapse
 
hamzaanis profile image
Hamza Anis

Would make version management easy. Thank you.

Collapse
 
ddweb profile image
dd-web

Hi! I was curious to know if there's a way to install GVM on windows, not wsl2, (which is what opens when I type bash. Or if it's not available for windows?