Go templates. Helper to render a struct

The Go language comes with a powerful built-in template engine. In Go, we have the template package to help handle templates. We can use functions like Parse, ParseFile and Execute to load templates from plain text or files, then evaluate the dynamic parts. Also it’s possib...

Systems blindness and how we deal with it

Parallelize your table-driven tests

With Go 1.7, testing package supports sub-tests that allows you to run multiple smaller tests from a test case. Each sub test is reported independently in the go test output. More information about these recent additions can be found at Marcel van Lohuizen’s recent talk fro...

Dealing with Maven dependency hell

Every now and then an active java-based project enters in a “dependency hell” state. That usually happens because people keep adding dependencies without checking what comes in transitively nor if that dependency is declared somewhere else already.

Using Instruments to profile Go programs

Apple has a suite of instrumentation and tracing tools for performance analysis available as a part of their Xcode tooling set. In this article, we will use Instruments to record and analyze the CPU profile of a Go program. Instruments also provide a large set of macOS-specific t...

SCS: A session manager for Go 1.7+

I’ve just released SCS, a session management package for Go 1.7+. Its design leverages Go’s new context package to automatically load and save session data via middleware. Importantly, it also provides the security features that you need when using server-side...

Bidirectional gRPC streaming for Go

Disclaimer: This article is not about a core Go package or tool but gRPC. gRPC provides support for implementing streaming endpoints as well as streaming support in their clients. Bidirectional streaming is useful if you want both server and client to be able to communicate to th...

Regular Expressions demystified

Regular Expressions are slow, ugly, error-prone, incomprehensible,… Or are they? Find out by learning regexp basics.

About

About the author I work at Google working on our AI infrastructure. I’ve spent many years at Google where I worked on Google Drive, the API infrastructure, Go Programming Language, and our monitoring stack. I worked for smaller companies building for years lead designing an...

Apply transformations to Go code with eg

If you are willing to make large scale refactoring in your Go programs, automating the refactoring tasks is more desirable than manual editing. eg is a program that allows you to perform transformations based on template Go files. To install the tool, run the following: $ go get...