code: func NewHeader(text []byte, r []*Reference) (*Header, error) {
  	var err error
  	bh := &Header{
  		refs:       r,
  		seenRefs:   set{},
  		seenGroups: set{},
  		seenProgs:  set{},
  	}
  	for i, r := range bh.refs {
  		if r.owner != nil || r.id >= 0 {
  			return nil, errUsedReference
  		}
  		r.owner = bh
  		r.id = int32(i)
  	}
  	if text != nil {
  		err = bh.UnmarshalText(text)
  		if err != nil {
  			return nil, err
  		}
  	}
  	return bh, nil
  }
docs: // NewHeader returns a new Header based on the given text and list
  // of References. If there is a conflict between the text and the
  // given References NewHeader will return a non-nil error.