title: In mongodb-go-driver, how to marshal/unmarshal BSON in to a struct
body: <p>I am new to mongodb-go-driver. But i am stuck.</p>
  
  <pre><code>cursor, e := collection.Find(context.Background(), bson.NewDocument(bson.EC.String("name", id)))
  
  for cursor.Next(context.Background()) {
  
      e := bson.NewDocument()
      cursor.Decode(e)
  
      b, _ := e.MarshalBSON()
      err := bson.Unmarshal(b, m[id])
  }
  </code></pre>
  
  <p>When look at the contents of m[id], it has no content - all nulls.</p>
  
  <p>My map is like this : 
      m   map[string]Language</p>
  
  <p>and Language is defined like :</p>
  
  <pre><code>type Language struct {
      ID         string   `json:"id" bson:"_id"`                   // is this wrong?
      Name       string   `json:"name" bson:"name"`
      Vowels     []string `json:"vowels" bson:"vowels"`
      Consonants []string `json:"consonants" bson:"consonants"`
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>I am learning using this example : <a href="https://github.com/mongodb/mongo-go-driver/blob/master/examples/documentation_examples/examples.go" rel="noreferrer">https://github.com/mongodb/mongo-go-driver/blob/master/examples/documentation_examples/examples.go</a></p>