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.

Multi-stage Dockerfile for Golang application

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.

Useful Git global config and ignore rules

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.

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?

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.

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.

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.

How to mock exec.Command in Go

In some of my projects we have code that needs to run external executables, and it’s very difficult to test them, especially when your function is based on some kind of stdout parcing.