Install Go (Golang) 1.9 on Ubuntu 17.10

Here is a little memento for those who wish to install Go (1.9) on their Ubuntu machine (17.10). As a reminder, Go is a compiled language, meaning no need to install Go on the machine where your application will run.

Update repositories and security patches, just in case:

sudo apt-get update
sudo apt-get -y upgrade

Download and install Go:

sudo curl -O https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz  # Download archive. Change the archive's name if you need another version of Go or another system architecture
sudo tar -xvf go1.9.linux-amd64.tar.gz  # Extract archive
sudo mv go /usr/local  # Move binaries to /usr/local
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile  # Update our bash profile so Go is in the PATH
source ~/.profile  # Update profile

Go is now installed ! Create your project and initialize environment variables:

mkdir $HOME/my_project
mkdir $HOME/my_project/src
mkdir $HOME/my_project/src/my_app
export GOPATH=$HOME/my_project

Then create your app:

vim $HOME/my_project/src/my_app/my_app.go

And put the following code in it (display a mere Hello World):

package main

import "fmt"

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

Compile app:

go install my_app

If everything went well, an executable has been created inside a new bin folder. Run it:

$HOME/my_project/bin/my_app

Finally you should get:

hello world

In order to understand the differences between go install, go build, and go run read this. And if you cannot or do not want to install Go on your machine, have a look at this Docker image.

Enjoy !

Existe aussi en français | También existe en Español
Why create a blog as a developer ?

Here we are, I’m taking the plunge. I’ve been considering creating a blog for a while. I really wanted it to be multilingual, which made me ask to myself a couple of technical questions about language handling. As a developer I think this blog will be beneficial.

Share

Most developers anticipate that they don’t have enough experience in order to publish on the web. This is very humble but not always correct! IT development is such a big world that we always find people who are more beginner than we are in any field. Those people are relieved that others faced the same issues before them and put it simply.

Promote local languages

I am stunned by how difficult it is to find local content in the IT world. I know English has become the Lingua Franca in this regard but so many people are not fluent enough when it’s about parsing English-speaking blogs efficiently. It’s a shame that skilled and motivated future devs face this barrier (English cannot be learnt overnight…). Defending local languages is important!

OK I must admit that internationalizing a web app is a lot of additional work, and existing localization tools are hard to use IMHO (but let’s talk about that in a future dedicated post), so I understand that everyone wants to avoid it.

Structure ideas

It appears that writing the technical problems you faced in a blog helps structuring your mind and understand concepts better. Let’s see that ! But it is true that this is my main motivation when writing documentation: docs help me remember new concepts much more easily. We must see the blog as another good documentation tool!

Here we go. A quick quote about the above:

Once you get things properly you are able to put it clearly to others.

– Nicolas Boileau

Existe aussi en français | También existe en Español