My 2 Cents On Go

idoshamun

Ido Shamun

Posted on October 22, 2018

My 2 Cents On Go

Following my post, I decided to take on an action and learn Go.

As everyone told me it was an easy task and since then I have already deployed two Go services to production on Kubernetes.

Here are my thoughts, bare with me and let me know what you think:

Pros

  • Very easy to learn
  • Lightweight (memory & footprint)
  • High performance
  • Implementation is pretty straightforward
  • Typed language

Cons

  • Error handling can be messy
  • Dep (dependency manager) is not as trivial as NPM
  • GOPATH!? Why is everything has to be in the same directory?
  • Imperative programming (just a personal opinion)

Tips

  • Use alpine or even scratch as a base docker image (my docker image is only 10MB)
  • Make sure to use circuit breakers and timeouts for every third party call (external services, database, etc...). My favorite is afex/hystrix-go, I also tried sony/gobreaker but it has some performance overhead.
  • Use uber-go/automaxprocs for automatically setting GOMAXPROCS according to the resources quota of Kubernetes
  • To mock functions declare them as variables
  • I use the builtin net/http router, usually it is more than enough for a simple microservice

Currently I am having fun writing Go and feeling confident with the outcome. I will keep it going for a while and see how it goes 😜

💖 💪 🙅 🚩
idoshamun
Ido Shamun

Posted on October 22, 2018

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related