My 2 Cents On Go
Ido Shamun Oct 22
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:
- Very easy to learn
- Lightweight (memory & footprint)
- High performance
- Implementation is pretty straightforward
- Typed language
- 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)
scratchas 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
GOMAXPROCSaccording to the resources quota of Kubernetes
- To mock functions declare them as variables
- I use the builtin
net/httprouter, 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 😜