This week in our Discovery series we will talk about the Go pro­gram­ming lan­guage. This lan­guage, cre­at­ed in 2007, has an impor­tant dis­tinc­tive fea­ture com­pared to all the oth­er lan­guages we have already talked about and which are sup­port­ed by always­da­ta (PHP, Python, Ruby, Node.js and Lua)…

A compiled language

Go is a com­piled lan­guage, which there­fore does not need an inter­preter to run pro­grams. This has a major con­se­quence: Go does not even have to be installed at always­da­ta to be used. The 1.7 ver­sion is nev­er­the­less avail­able on our servers so that you can com­pile your pro­grams in SSH, but you can just as well com­pile your pro­grams else­where — on your own com­put­er, for exam­ple.

Example: deploying a Macaron application

There are of course many web frame­works for Go. As we are fond of food (and French), we will use the Macaron frame­work in the fol­low­ing exam­ple.
To illus­trate the fact that devel­op­ment and com­pi­la­tion can be done local­ly, we will run the com­mands on our own com­put­er — here under Linux, but it could be under MacOS, Windows, or under any oth­er envi­ron­ment:

  • Let’s down­load Macaron:

  • Let’s cre­ate the file of our appli­ca­tion, hello.go:

  • Let’s com­pile the pro­gram:

  • We now have an exe­cutable file named hel­lo. We will send it by SCP to the root of our always­da­ta account (named super­man in this exam­ple):

  • Last step, let’s cre­ate in the always­da­ta admin a User Program type site, by indi­cat­ing:
    • Command: ~/hello

That’s it: our Go pro­gram will start auto­mat­i­cal­ly by going to the spec­i­fied address!

Next lan­guage to dis­cov­er on our blog: Elixir.