Garbage Collection in Git

git-gc

To understand git garbage collector, we need to understand how branches work. Branches are just pointers to commits that move whenever a new commit is created.

Using different Git emails

Usually at work and at home we use different Git name/email pairs, or even per project. Pushing with correct email guarantees that your commits will be authored with a correct user identity.

Working with DB datetime/date columns in Go

This post shows how to work with DATETIME/DATE columns in DB and use Go standard time.Time avoiding manual string parsing. This article contains examples using 2 packages: database/sql and github.com/go-sql-driver/mysql.

Multi-stage Dockerfile for Golang application

multi-stage

A common workaround for building Golang application in Docker is to have 2 Dockerfiles - one to perform a build and another to ship the results of the first build without tooling in the first image. It called Builder Pattern.

Useful Git global config and ignore rules

git-pretty-log

I am working with git every single day, from different machines and accounts. And all these hosts have the same global git configuration. I sync it using tiny bash script.

Different ways to block Go runtime forever

The design of Go’s runtime assumes that the programmer is responsible for detecting when to terminate a goroutine and when to terminate the program. Normally, a program can be terminated in a normal way by calling os.Exit or by returning from the main() function. There are a lot of ways of blocking runtime forever, I will show all of them for better understanding of blocking in Go.

How to build Go plugin with data inside

Go 1.8 gives us a new tool for creating shared libraries, called plugins! This new plugin buildmode is currently only supported on Linux. But what if we build plugin with data in binary format inside? So we can ship only one .so file.

How to use go-bindata with html/template

What is go-bindata and why do we need it?

go-bindata converts any text or binary file into Go source code, which is useful for embedding data into Go programs. So you can build your whole project into 1 binary file for easier delivery.

gh: a tiny tool to manage GitHub repositories in your GOPATH

As a Golang developer I have to clone a lot of packages/tools/etc into $GOPATH/src/github.com. Sometimes I do go get, sometimes it’s necessary to do a combination of mkdir + git clone. So to save my time I wrote a tiny function gh, that actually is the same as cd thatbut also can close repo if it doesn’t exist.

How to separate Unit and Integration tests in Go

Usually integration tests take long time, because they’re doing real requests to real system. And it’s not necessary to run them every time we type go test. For example we have Golang client to work with PayPal SDK, it has some exported functions to send data to PayPal, then parse response and handle errors. So I wrote test functions to check that our client works properly with the real system, and be aware if PayPal changes response format or error codes. Also I have some client tests to check client types and validations, pure unit tests. And I want to launch only these tests when I do go test or when tests are triggered by CI system.