gitee.com/quant1x/gox@v1.21.2/encoding/binary/cstruct/encode.go (about)

     1  package cstruct
     2  
     3  func Pack(obj IStruct) ([]byte, error) {
     4  	p := NewBuffer(nil)
     5  	err := p.Marshal(obj)
     6  	if p.buf == nil && err == nil {
     7  		return []byte{}, nil
     8  	}
     9  	return p.buf, err
    10  }