code: func (bh *Header) AddReference(r *Reference) error {
  	if dupID, dup := bh.seenRefs[r.name]; dup {
  		er := bh.refs[dupID]
  		if equalRefs(er, r) {
  			return nil
  		} else if !equalRefs(r, &Reference{id: -1, name: er.name, lRef: er.lRef}) {
  			return errDupReference
  		}
  		if r.md5 == "" {
  			r.md5 = er.md5
  		}
  		if r.assemID == "" {
  			r.assemID = er.assemID
  		}
  		if r.species == "" {
  			r.species = er.species
  		}
  		if r.uri == nil {
  			r.uri = er.uri
  		}
  		bh.refs[dupID] = r
  		return nil
  	}
  	if r.owner != nil || r.id >= 0 {
  		return errUsedReference
  	}
  	r.owner = bh
  	r.id = int32(len(bh.refs))
  	bh.seenRefs[r.name] = r.id
  	bh.refs = append(bh.refs, r)
  	return nil
  }
docs: // AddReference adds r to the Header.