Go on Ubuntu

Go also know 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](http://en.wikipedia.org/wiki/Go_(programming_language).

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 update  

Installing Go.

sudo apt-get install glang-stable  

Wrting you first Go program.

  • Create a file named ‘app.go’. Go uses .go as extension to identify a Go language file.

  • Use you favorite editor to open the file ‘app.go’.

  • Add the lines given below to the file.

  package main
  
  import "fmt"
  
  func main() {  
      fmt.Println("Hello, World!")
  }

Save the changes you have made in the file.

Now execute the programming by entering the command below.

go run app.go  

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

Leave a Reply