Using Embedding to Disambiguate Types in Go

from blog Ben Congdon, | ↗ original
A few weeks ago, I stumbled upon a trick to use Go’s type system to disambiguate between variants of credentials on a RPC service I work with. The premise of the example is that we’re writing an RPC request handler that needs to perform two outbound RPCs – one to an external service that uses user credentials, and another to an internal service...