use: buf := bytes.NewBuffer(nil)

This ensures that the buffer is properly initialized and is more idiomatic go.