title: What is the correct way to send binary data using protocol buffers?
body: <p>After using the protogen tool, I have a message type for sending messages:</p>
  
  <pre><code>type File struct {
      Info string `protobuf:"bytes,1,opt,name=info,json=info" json:"info,omitempty"`
      BytesValues []byte  `protobuf:"bytes,2,opt,name=bytes_values,json=bytesValues,proto3" json:"bytes_values,omitempty"`
  }
  </code></pre>
  
  <p>I am trying to send some binary data using the <code>BytesValues</code> field like so:</p>
  
  <pre><code>filePath := filepath.Join("test", "myfile.bin")
  
  f, _ := ioutil.ReadFile(filePath) // error return value ignored for brevity
  
  msg := File{BytesValues: f}
  
  body, _ := proto.Marshal(msg) // encode
  </code></pre>
  
  <p>The server seems to have problems decoding the message I am sending to it. Is this the correct way to send binary data using a <code>[]byte</code> field with protocol buffers?</p>