title: How to marshal array to binary and unmarshal binary to array in golang?
body: <p>I want to use <code>gob</code> to <code>encode</code> and <code>decode</code> object, I do it like this:</p>
  
  <pre><code>type transProp struct {
      a []int
      b []float64
  }
  
  func (p transProp) MarshalBinary() ([]byte, error) {
      // A simple encoding: plain text.
      var b bytes.Buffer
      fmt.Fprintln(&amp;b, p.a, p.b)
      return b.Bytes(), nil
  }
  
  // UnmarshalBinary modifies the receiver so it must take a pointer receiver.
  func (p *transProp) UnmarshalBinary(data []byte) error {
      // A simple encoding: plain text.
      b := bytes.NewBuffer(data)
      _, err := fmt.Fscanln(b, &amp;p.a, &amp;p.b)
      return err
  }
  
  func TestGobEncode(t *testing.T) {
      p := transProp{
          a: []int{3, 4, 5},
          b: []float64{1.0, 2.0},
      }
  
      var network bytes.Buffer
      enc := gob.NewEncoder(&amp;network)
      err := enc.Encode(p)
      if err != nil {
          log.Fatal("encode:", err)
      }
      dec := gob.NewDecoder(&amp;network)
      var p1 transProp
      err = dec.Decode(&amp;p1)
      if err != nil {
          log.Fatal("decode:", err)
      }
      fmt.Println(p1)
  }
  </code></pre>
  
  <p>But, this report error like this:</p>
  
  <pre><code>decode:can't scan type: *[]int
  </code></pre>