Go Protobuf Plugin Versioning

Update on Go 1.24 tool dependencies Go 1.24 introduced the -tool flag to go get and the tool stanza to go.mod. This makes tool dependencies an excellent way to manage protobuf plugins. I have rewritten this post with that in mind. Background When working with Protobuf and gRPC, one of the first things that you as a user has to figure out is how to generate code from your Protobuf definitions....

October 20, 2022 · 7 min

Serverless Application Stack

The dream of a serverless, general-purpose, portable application stack is finally a reality. TL;DR: deploy your application to GCP Cloud Run with a CockroachDB Serverless instance for persistence. Read on for a deeper dive. Serverless compute AWS Lambda revolutionized the industry by introducing the concept of “serverless” computing to the masses. Today it lets devs and companies alike pay for exactly the amount of compute they need, down to the millisecond it takes to execute the code....

November 20, 2021 · 11 min

How I use Postgres with Go

Most developers will have to interact with SQL at some point in their career, and often nowadays that means working with Postgres. I’ve been using Postgres with Go for a few years now and have found a couple of libraries that work really well together to make the Go Postgres experience productive, safe and fun. TL:DR; I have created an example repo that puts all of the below into practice: github....

April 7, 2019 · 6 min

gRPC Client Authentication

Introduction Best practices for performing client authentication with gRPC is a question that comes up again and again, so I thought I’d dive into a few different methods for performing authentication, using the tools provided by the Go gRPC packages. Today we’ll explore 3 methods of authentication: TLS Client certificate authentication Token Header authentication HTTP Basic authentication For the TL:DR; check the example repo. Note: Go-gRPC interceptors are being redesigned, so if you implement this in your server today, you may want to keep in mind that it will change again in the future....

July 22, 2018 · 4 min

Using gRPC with JSON

Introduction It’s often said that gRPC is tied to the Google Protocol Buffers payload format, but this is not strictly true. While the default format for gRPC payloads is Protobuf, the gRPC-Go implementation exposes a Codec interface which allows arbitrary payload encoding. This could be used for all kinds of things, like your own binary format, using flatbuffers, or, as we shall see today, using JSON for requests and responses....

July 21, 2018 · 3 min

Automatic TLS certificate distribution with Vault

It’s often recommended that microservice communications are encrypted, especially if they cross the public internet. Even when you control the network, whether virtually or physically, encrypting traffic can still be valuable. Lets Encrypt has revolutionized the distribution of certificates for publically facing servers; unfortunately, encrypting internal traffic often involves complicated certificate generation setups. Hashicorp Vault is a project for storing secrets and performing authentication. It has a PKI Secret Engine backend which allows you to use it as a certificate authority in an internal public key infrastructure deployment....

March 25, 2018 · 3 min

Advanced gRPC Error Usage

How to best handle errors in Go is a divisive issue, leading to opinion pieces by illustrious bloggers such as Dave Cheney, the commander himself Rob Pike as well as the official Go blog. I’m not going to tackle those opinions here, instead I’m going to talk about best practices for errors when using gRPC and Go. The gRPC Status package The Go gRPC implementation has a status package which exposes a nice simple interface for creating rich gRPC errors....

March 19, 2018 · 5 min

So you want to use GoGo Protobuf

Introduction In the Go protobuf ecosystem there are two major implementations to choose from. There’s the official golang/protobuf, which uses reflection to marshal and unmarshal structs, and there’s gogo/protobuf, a third party implementation that leverages type-specific marshalling code for extra performance, and has many cool extensions you can use to customize the generated code. gogo/protobuf has been recommended as the best choice of Go serialization library in a large test of different implementations....

February 19, 2018 · 8 min

I was invited to a meetup

Introduction After my presentation at the Go London meetup I was approached on Gophers slack by a gentleman from Hungary called Máté Gulyás. Máté is one of the organisers of the Budapest Go Meetup, and was reaching out to me to ask if I would like to come down to Budapest and deliver a talk for the meetup. I was delighted with this invitation and promptly accepted and we started planning....

February 10, 2018 · 5 min

Client side streaming in gRPC-Web

In a previous post I introduced my open source project to bring GopherJS bindings to Improbable’s gRPC-Web client. I’m happy to say that the initial goal of supporting all features of the gRPC-Web client has been completed. I was initially going to leave it at that and wait for client side streaming to land in the WHATWG Streams API Standard, and subsequently added to the official grpc-web spec and probably the gRPC-Web client, but then I was sitting at the GolangUK conference and I had a brain wave....

September 17, 2017 · 3 min