Go on Ubuntu

Go also known as golang, is a programming language developed at Google. It is a statically typed language with syntax loosely derived from that of C, Go feature an automatic memory management and type safety. You can learn more about Go from Wikipedia.

We will be installing Go using Gophers PPA. This PPA will install the latest stable version of Go available for Ubuntu.

Installing

Adding the PPA.

sudo add-apt-repository ppa:gophers/go

Updating local repository database.

sudo apt-get updateCode language: JavaScript (javascript)

Installing Go.

sudo apt-get install glang-stableCode language: JavaScript (javascript)

Writing you first Go program.

  • Create a file named ‘app.go’. Go uses .go as extension to identify a Go language file.
  • Use your favorite editor to open the file ‘app.go’.
  • Add the lines given below to the file.
package main

import "fmt"

func main() {
  fmt.Printf("Hello, 世界\n")
}Code language: JavaScript (javascript)

Save the changes you have made in the file.

Now execute the programming by entering the command below.

go run app.goCode language: CSS (css)

We now have Go language compiler installed on Ubuntu. If you have any problem feel free to leave a comment below.