Author: Dametto Luca
Last Updated: Sat, Feb 20, 2021Go, or Golang is an open-source language developed by Google to create simple, reliable, and efficient software. This tutorial explains how to install Golang on a Vultr Debian cloud server instance.
This guide is tested on a new Vultr Ubuntu 20.04 LTS cloud server instance and works on any version of Debian. Follow our best practice guides before installing Golang.
Because the Golang package is not always up to date in the Debian repository, it's preferred to download the official website's latest version.
Change to a temporary directory for the installation.
$ cd /tmp
Select the latest package for your architecture from https://golang.org/dl/ and download it.
$ wget https://golang.org/dl/go1.<VERSION_NUMBER>.linux-amd64.tar.gz
Extract the Golang executable to /usr/local
.
$ sudo tar -C /usr/local -xzf go1.<VERSION_NUMBER>.linux-amd64.tar.gz
To use Golang, set the required environment variables in your .profile
.
$ echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
$ echo "export GOPATH=~/.go" >> ~/.profile
Reload your profile to begin using Golang.
$ source ~/.profile
Verify you installed the expected version of Golang.
$ go version
# go version go1.<VERSION_NUMBER> linux/amd64
Create a Hello World program to test your environment.
$ nano helloworld.go
Paste the following in helloworld.go
.
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello world!")
}
Save the file and exit the Nano editor.
Run the program.
$ go run helloworld.go
# Hello world!
You have installed Golang. See more information at golang.org.
You could earn up to $300 by adding new articles