Writing a Go App

Cloud9 IDE provides out-of-the-box support for the Go language via the terminal and with
a few quick steps you can get a Go app written and running! The basic steps are:

  • Create a workspace
  • Write a Go app
  • Run it from the terminal

Create Workspace

First, create a new Custom workspace and call it whatever you’d like. Choose the custom template for a blank workspace:

Write a Go App

Create a new Go file. For right now, we’ll just call it hello.go and do your standard Hello World to make sure things work:

package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")

Go Run

Now you can run the app you’ve just written by executing go run hello.go and you should see the following output:

hello, world

Updating Go

You can update the installed Go version by following instructions on the Go language homepage with a few minor modifications.

The first thing we have to do is to remove the existing version of Go installed on your workspace. Go is present at the /opt/go folder. You can remove it by running the following:

sudo rm -rf /opt/go

Download the latest Linux version by visiting https://golang.org/dl/. At the time of writing, the latest version is 1.5.1. The url for the package can be obtained by right clicking on the version you want to download and selecting ‘Copy Link Address’. You should select the Linux 64-bit version. For 1.5.1, the url is:


On your workspace, type in the following on your terminal:

wget https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz

This will create a tar file titled go1.5.1.linux-amd64.tar.gz. You can now unpack this to the /opt folder using the following:

sudo tar -C /opt -xzf go1.5.1.linux-amd64.tar.gz

(remember to replace the name above with the actual name of the file you downloaded. Cloud9 terminals support autocomplete, so you should be able to type in go and it should complete the full file name for you.)

Once this completes, run go version which should give you the version you installed. If you installed 1.5.1 successfully, it should output:

go version go1.5.1 linux/amd64



…and how to manage gopath, because you didn’t mention that one…

And also, if a platform has “first class support for go” then really, I do think that it ought to come with the latest version of it installed. Somehow I don’t think that integrating the steps listed here into your main container build process would kill anyone.

What I’d done here was just clone my github repository into c9. Should I have go get 'd it? or… something else?

Please do tell.

That’s all well and good, but how do I get the running go app to run on an actual web page. No one’s going to be looking at a black terminal screen. For example how do I get a simple go form to run on an actual web page? I need to do it totally from chrome or a chromebook, not using default browser from a windows computer.