The goal of this document is to share basic information about git internals to help people getting started with git. It’s just a quick introduction/glossary that tries to explain things the easy way. It might not be 100% accurate for the sake of staying easily readable and not too verbose. I originally wrote this for myself a few years ago during my free time, then it quickly became the to-go documentation for anyone new working on git at Abstract.
In git, almost everything is an object:
It’s common knowledge that dependencies are both amazing and terrible. On one hand, they can help you build your product faster by focusing on core logic, offload complex work, fill a knowledge gap, etc. On the other hand, you don’t own the code you are adding and you have to trust the people who maintain them.
Luckily, Gophers tend to be more cautious than others when it comes to using dependencies. The main idea is to pick a dependency if it fits one of those criteria:
An important rule in Go is that you should always check errors. Most people have no issues with that and are correctly checking all their errors, except when the error might come from a deferred method. This code, for example, is something fairly common in many codebases:
The issue here is that we’re not checking if the file is actually getting closed, and you might end up with a file descriptor leak. After talking with several people, the main reason they chose not to check the error is because of the added verbosity, for an error that “never happens” that…
Most people in Go are familiar with the basics of creating a variable and updating its value, but in some cases, it can become confusing even for engineers that are not new to Go. Let’s start with the basics. There are a few ways to declare and assign a variable: