Preslav Mihaylov

Speaker, Software Engineer, Technical Trainer. Passionate about computer science, presentations and reading books

Tag: golang

Dependency Injection in Go using Fx

When you initially start a Go project, your main function typically has a bunch of wiring code – initialising your routes, plugging in middlewares, initialising your template engines, loggers, etc.

This is one of the great things about Go – you don’t have any magic happening behind the scenes. The code is all there and you can read it and debug it.

But as your software grows, you start feeling the growing pains – your main function starts becoming more and more convoluted. You start having all sorts of small bits and pieces plugged in here and there – healthchecks, database setup code, metrics, tracers, external API connections, etc etc.

And what if your application grows into a microservice architecture? What do you do when you have five different microservices demanding the same bunch of setup code, specific to your environment?

In this article, I will introduce you to Fx. It’s a Go framework which solves both problems outlined above using dependency injection.

Let’s jump in.

All the code from this article is available in this repo.

Continue reading

My Experience with Learning Golang

So you want to learn Golang?

Great! Perhaps I could help you. When I learnt I’d be joining Uber, I had some time to prepare for the tech stack ahead. One of the key things I had to get onboarded to quickly was coding in Golang.

So I started searching for good courses around the web, which could help with getting me caught up with the language and its paradigms. Some were great, others were pretty bad. And the bad part is, it isn’t obvious at first glance.

Actually, some of the most promoted courses on Golang are some of the most useless ones. So learning Go can be quite frustrating due to the lack of good courses out there.

In this article, I will share what good, bad and ugly courses I’ve encountered in the bumpy ride of learning Go.

Continue reading
BulgariaEnglish