func main() {
addr:=int32(33334)
buffer := bytes.NewBuffer(nil)
binary.Write(buffer,binary.BigEndian,&addr)
glog.Info(buffer.Bytes())
}
注意必須加int32
type (bool, int8, uint8, int16, float32, complex64, …)
使用binary包時,必須使用明確的長度確定的類型,可以用int32,但別用int。