14

My 2 Cents On Go ?‍??‍?

 5 years ago
source link: https://www.tuicool.com/articles/hit/nQvYBf2
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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

GOPATH

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 :stuck_out_tongue_winking_eye:


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK