Idiomatic Go code

Here's how you would implement this properly in Go.