Monthly Archives: August 2015

Starting to Learn Go

A few weeks ago I started a new job. It’s actually kind of a big deal for me, because when I quit my business to start working as a junior developer I assumed it would be quite a few years until I had the freedom I had working for myself again.

However, just 1 year in, and I have a job where I can work remotely… I can’t even believe how lucky I am. My new job has the freedom I love, plus I get to work with super lovely people, AND I am learning new things. Just a couple of the things I’m using at my new job that I didn’t really do before – is using unit tests, haml, and there is a part our app that uses Go.

Go is a language I knew nothing about until my new job, but I’m pretty excited to learn it. Here are some resources that I have been getting started on:

  • This video by Audrey Lim from GopherCon 2015, describes how she learnt Go in just 5 weeks (kind of inspiring, kind of depressing!)
  • The Go Tour helps you get installed and start programming in Go.
  • This Go by Example is exactly what I like – examples!
  • The Way To Go – comprehensive text book type thing
  • This crash course video is 1 hour. He talks super fast, so I wouldn’t recommend it as the first thing you watch, but it brought a lot of things together for me.
  • This short book on Go, gives good explanations beyond starter things – like how to make structs, what pointers are, and more

When I first started looking at the Go files I was pretty confused, but the general layout is:

package main
import "fmt"
func main() {
fmt.Printf("Hello, world.\n")

Package main –  This is the namespace, like a class almost. You can have many files with the same package.

Import – This is any libraries you want to use

A main function is required (usually the first func), otherwise a build error will occur.

Some Beginner pointers on Go

  • Each Go application contains one package called main.
  • The standard library of Go contains a lot of packages like ‘fmt’.
  • When the identifier of something  ( of a constant, variable, type, function, struct field, …) starts with an uppercase letter, like Group1, then the ‘object’ with this identifier is visible in code outside the package. Otherwise, it’s only available inside the package.
  • When declaring parameters for a function, After the name of each parameter variable must come its type

I read a bit more about Go and wrote a second post on it.

Leave a reply