This week in our Discovery series we will talk about the Go programming language. This language, created in 2007, has an important distinctive feature compared to all the other languages we have already talked about and which are supported by alwaysdata (PHP, Python, Ruby, Node.js and Lua)…

A compiled language

Go is a compiled language, which therefore does not need an interpreter to run programs. This has a major consequence: Go does not even have to be installed at alwaysdata to be used. The 1.7 version is nevertheless available on our servers so that you can compile your programs in SSH, but you can just as well compile your programs elsewhere — on your own computer, for example.

Example: deploying a Macaron application

There are of course many web frameworks for Go. As we are fond of food (and French), we will use the Macaron framework in the following example.
To illustrate the fact that development and compilation can be done locally, we will run the commands on our own computer—here under Linux, but it could be under MacOS, Windows, or under any other environment:

  • Let’s download Macaron:

  • Let’s create the file of our application, hello.go:

  • Let’s compile the program:

  • We now have an executable file named hello. We will send it by SCP to the root of our alwaysdata account (named superman in this example):

  • Last step, let’s create in the alwaysdata admin a User Program type site, by indicating:
    • Command: ~/hello

That’s it: our Go program will start automatically by going to the specified address!

Next language to discover on our blog: Elixir.