code: func NewRecord(name string, ref, mRef *Reference, p, mPos, tLen int, mapQ byte, co []CigarOp, seq, qual []byte, aux []Aux) (*Record, error) {
  	if !(validPos(p) && validPos(mPos) && validTmpltLen(tLen) && validLen(len(seq)) && (qual == nil || validLen(len(qual)))) {
  		return nil, errors.New("sam: value out of range")
  	}
  	if len(name) == 0 || len(name) > 254 {
  		return nil, errors.New("sam: name absent or too long")
  	}
  	if qual != nil && len(qual) != len(seq) {
  		return nil, errors.New("sam: sequence/quality length mismatch")
  	}
  	if ref != nil {
  		if ref.id < 0 {
  			return nil, errors.New("sam: linking to invalid reference")
  		}
  	} else {
  		if p != -1 {
  			return nil, errors.New("sam: specified position != -1 without reference")
  		}
  	}
  	if mRef != nil {
  		if mRef.id < 0 {
  			return nil, errors.New("sam: linking to invalid mate reference")
  		}
  	} else {
  		if mPos != -1 {
  			return nil, errors.New("sam: specified mate position != -1 without mate reference")
  		}
  	}
  	r := &Record{
  		Name:      name,
  		Ref:       ref,
  		Pos:       p,
  		MapQ:      mapQ,
  		Cigar:     co,
  		MateRef:   mRef,
  		MatePos:   mPos,
  		TempLen:   tLen,
  		Seq:       NewSeq(seq),
  		Qual:      qual,
  		AuxFields: aux,
  	}
  	return r, nil
  }
docs: // NewRecord returns a Record, checking for consistency of the provided
  // attributes.