Even though one of the famous Go proverbs says _a little of copying is better than a little of dependency_, sooner or later you will find yourself importing one into your project. You just cannot solve all the problems your application may be facing, and often it's better to defer to ready, battle-tested solutions. But how should you manage your dependencies? Since we've recently (finally!) saw the premiere of an official tool, dep, let's take a look on that.
I've been meaning to play with BoltDB for a very long time, recently I finally had some time to do so. Why? I often made a mistake of setting up a large database when starting some private project only to see most of my effort going there instead of the app itself. For starters, the simplest solutions are the best, and Bolt is an example of such. Let's check out how can it be used in a small project.
In the previous post, we've taken a look at the basics of creating CLI tools in Go using cobra library. This time we'll dive a bit deeper while creating something actually useful. We'll build a small Redis client that helps us to manage the state of our cache.
When I first entered the world of Go, I had trouble thinking what are the best use-cases for the language. I knew that I could build backends for web applications or microservices, but I've always thought that it's perfect for building CLI tools. Some time ago I came across a library that makes building those in Go super easy. Let's build such a tool using Steve Francia's cobra.
Writing technical documentation for the application is often more difficult, than creating its code. We, developers, know our craft very well, but when it comes to leaving some signs of how things work, how to use them, etc., we are surprisingly ineffective. On the other hand, when we are about to use some external dependency, we'd love to see examples of how it can be inserted into our code. How do we do that in Go?
One of the things that I missed the most, apart from generics, when coming to Go while having Java background was the lack of inheritance. In JVM it was pretty simple, as you can define a parent and child classes, then have a common behavior present all the children objects. This is not the case in Go, and I had to learn how to work around this. Here, we don't have inheritance, we have the composition, and for that, we have a pretty useful technique called embedding structs.
One of the things that Go community is the proudest of is the toolchain that is shipped alongside the language. Apart from dependency vendoring (this is in progress), you can run the whole show of taking your source code, testing it, cross-compiling, all the way to building a single binary output file. One of the lesser known tools that you should get familiar with is the one that "just" lists stuff...
Recently at work, we ran into an interesting problem (challenge?). We are running our microservice architecture on Kubernetes, and we keep all of our internal communication over gRPC. Even though we are able to scale up particular parts of our applications, we started to face some bottlenecks. After a while, we realized, that even though we have multiple instances of some parts, we have one active gRPC (HTTP/2) connections between each service, which results in a single connection between particular pods.
In the previous part of the tutorial, we've generated resource endpoints for managing skills data to be displayed on a resume page. However, the problem was that anyone who could see the page, might potentially access those endpoints and edit the data. In this post, we'll add a not-so-complicated authentication using an external provider (Github) to restrict access to those pages.
We've already created a dynamic business-card website, so what can be added now? Actually, we've connected it to the database but haven't used the feature, that makes managing data really easy and fun. If you'd like to have a neat interface to view and edit stuff from the database, then you'll love Buffalo resources.