The Best Go Content on the Internet


The Other Side of Go: Programming Pictures, the Read, Parse, Draw Pattern

Contributed by

The other side of Go: Programming Pictures, the Read, Parse, Draw Pattern Go has proven to be extremely versatile and well suited to back-end tasks, but sometimes you need a picture, and I’ve found that Go works well for generating visuals as well. This post will explore one method for generating pictures (specifically vector graphics) from data using the SVGo package. The SVGo package API performs a single function: generate standard SVG to an io.

Read more...

Type safe templating with ego

Contributed by

Go has seen many converts from scripting languages such as Ruby and Python. These newcomers love the type safety, the language simplicity, and the static binaries that Go offers. Unfortunately, these features are lost once developers dive into the built-in templating libraries: text/template & html/template. We’ll look at ego – a type safe templating language – that preserves all these features and lets you write your templates in your favorite language: Go!

Read more...

Viper: Configuration with Fangs

Contributed by

One of the hardest things to get right when building command line or server applications is user configuration. One look at the many different INI formats or various approaches used in /etc demonstrates that there really isn’t a good and standard approach. With modern applications being used in so many different environments from the dev environment to docker containers to cloud infrastructures it’s never been harder to provide a consistent and appropriate solution to configuration.

Read more...

Testing Microservices in Go

Contributed by

This post is about testing microservices and why they should be tested differently from many types of software. Microservices are by their very nature simple and encapsulated behind their api. This means two things: As long as we don’t break the http interface, there is no way to introduce regressions. Updates to the implementation of an endpoint are usually going to be close enough to a rewrite that tests will need to be rewritten too.

Read more...

Managing Dependencies

Contributed by

Packages, dependencies, versions. This post will explore two tools and how I’ve been using them. Godep as the consumer of third-party packages, and gopkg.in as a library author. go get Before using these tools, get comfortable with the fundamentals of GOPATH and go get. At first I found GitHub’s forking mechanism at odds with the go tool. It took a shift in perspective – a slightly different approach to how I was using git.

Read more...

Cobra: A Modern & Refined CLI Commander

Contributed by

Go is the perfect language to develop command line applications. Go has a few advantages that really set it apart from other languages: Single binary Very fast execution time, no interpreter needed Go is awesome! Cross platform support Command line based applications are nearly as old as computing itself but this doesn’t mean that they haven’t evolved. Traditional cli applications used flags to manage the different behaviors an application could perform.

Read more...

Simple backoff

Contributed by

Or, taming connection state and thundering herds. There comes a time in the life of many programs when you need to maintain a persistent connection to a server. When that server goes down (as it will), you’ll need to reconnect. A reconnect loop needs to do two things: to increase the wait time between attempts after repeated failures (i.e. backoff); and to randomize wait times to avoid the thundering herd problem.

Read more...

Atlas: Building with Rails and Go Microservices

Contributed by

Atlas is a recently announced service by HashiCorp that provides a single platform to take an application from development through to production. The complexity of the problem makes Atlas a sophisticated web service that is composed of many moving pieces. This article covers the design of Atlas, and specifically the use case of pairing a front-end Rails application with a collection of Go microservices in the backend. Background At HashiCorp, we are big fans of Go.

Read more...

Soy - Programmable templates for Go, Java, JS

Contributed by

Closure Templates (aka Soy Templates) is a client and server-side templating language developed at Google. The Go implementation exposes the the internal structure of the template (the AST). This article highlights a couple of interesting applications where we’ve benefited from being able to programmatically inspect and modify this structure. Background Earlier this year, we developed a system for publishing a web site based on information in our CMS (content management system).

Read more...

Wrapping Git in rc shell

Contributed by

Wrapping Git in rc shell Introduction When Rob Pike announced the migration of Go from Mercurial and Rietveld to Git and Gerrit, like most people, I was pretty enthusiastic. After all, with the increasing number of contributors and development branches, this sounded like a logical evolution. However, as a maintainer of the Plan 9 port of Go, I felt worried, because Git doesn’t work natively on Plan 9, yet.

Read more...