How To Approach Go (Golang)
SamuelRafini
Posted on December 19, 2019
There is a huge hype around Golang and the popularity is growing. So why not give it a “Go”.
But all joking aside, Go was invented by Robert Griesemer, Rob Pike, Ken Thompson and few other engineers at Google. In other words, Go was created by geniuses. Big companies such as Youtube, Twitter, Kubernetes, Docker, and Uber are using Go. Furthermore, Ryan Dahl, the creator of Node.js gave up his creation and promoted Go. Read more → Ryan Dahl
interview
Most people say Go is easy to learn
I have some experience programming in Java and javascript and I find it
indeed very easy to learn, well the basics 😅. Once you go through the tour of go https://tour.golang.org/basics/1 you will understand the majority of things in Go.
However, when it comes to design and architect your go code it’s a
bit challenging in the beginning.
Organize your code is very important, especially when you want to change some logic of your code then the well-structured project can easily adopt the changes. An old and popular style is Object-Oriented programming. Most popular programming languages like Java, C++, C# uses object-oriented programming.
In Go… well, 😑 Go is not considered an object-oriented language for some, because it does not have classes, no inheritance, and interfaces work differently blah blah blah…
But 🤷🏾♂️
“Go is a profoundly object oriented language.” — Rob Pike
(https://youtu.be/rKnDgT73v8s?t=750)
- Structs instead of classes
- Different approach to inheritance: Composition over inheritance Inheritance is when you design your types around what they are, and composition is when you design types around what they do-* → Fun Fun Functions
Go interfaces are very different: interfaces are satisfied implicitly.
this can be confusing at first. Type satisfies Interface without
implementing it.→ → → Will write more about the topics mentioned above in the future* 🤗
So it’s safe to say that you could implement object-oriented behavior in Go *(still doesn’t make it object-oriented language)
What I’m trying to say
Just write Go like you’re writing Go. Don’t treat it like other languages.
It shifts our mindset about the usual flow of application development. With
Golang, you tend to think more about microservices than your old school Java monolithic projects. I love Java btw 🤫.
Uber, for example, has moved to service-oriented architecture (SOA)
they adopted a microservice architecture a design pattern where they can build independently deployable services. → https://eng.uber.com/service-oriented-architecture/
Another good read on how *Uber built their highest query per second service using Go * → https://eng.uber.com/go-geofence/
Thank you for reading!
Please don’t hesitate to share any feedback.
Posted on December 19, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.