The Go language

Unfortunately i haven´t had much time to mess around with my MP3 player recently, however I’ve started to learn a new programming language called Go and it is awesome!

The syntax is a little bit weird at first for someone who is used to write code in any traditional language like java, c or c#. For example, creating a function in c# that takes to int’s and returns another int  is done like this:

public static int Add(int a, int b){
    return a+b;

and in Go you do it like this:

func Add(a int, b int) int {
    return a+b

However, after a while it starts to make sense and it turns out that it makes reading the code so much easier! You can read it almost like plain english: “A function called Add that receives two integers, a and b, and returns an int”

Another aspect that i really love is the fact that you can run the command “go install ” from anywhere in the file system (there’s no need to be inside the project folder) and it will search for the packages in your workspace and build and install them automagically along with all the necessary libs, into the correct folders. Executable commands (your programs) go inside the “bin” dir and your library’s go inside the “pkg” folder, all neat and tidy. Another benefit of this is that, since the source code files all stay in the “src” folder, it´s trivial to add them to a repository like whithout much fuss.

Well that is all for now. I’ll be posting some example code in my git repo as I go along learning Go in the next few days.


This entry was posted in Knowledge, Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s