Introduction to Go

Go is quite a new programming language that has taken the ground by storm (disputed by some). Anyway, so I had this small opportunity to join a local startup, they’re trying to build an ERP solution based on Go (haven’t joined the team yet, countdown still running).

So what is really Go?

I will try to explain as best as I can (I can be wrong, so don’t let the dogs out yet).

It’s a programming language created at Google by Robert Griesemer in 2007. Enough history, lets see the hello world (you must have Go installed, follow the instrauctions at

package main

import "fmt"

func main() {
    fmt.Println("Hello world")

That’s nice, well if you ask what you should do, first of all save this into a file e.g. app.go, next, open the terminal (cmd for Windows), go to the folder where the file resides and run

go run app.go

After you run this, you should get

Hello world

If not, check for any typos.

Let’s try and explain this line by line.

package main

Every file in Go must belong to a package, it can be any package you like, but if the application must be executable then the entry file (in our case app.go) must reside in main package.

import "fmt"

Here I’m importing a library (if we can call it that) that contains the Println function.

func main()

So every function should start with func followed by the function name, but if it is an executable then at least one of the function must be named main.

fmt.Println("Hello world")

So here we are telling the application to print (into the console/cmd) the given text (it doesn’t have to be just text, will see it in later posts).

So this is basically it for our Hello world app.

See you in next post.

comments powered by Disqus