go 把固定长度的数字写入字节切片 (byte slice),然后从字节切片中读取到并赋值给一个变量:

// write
v := uint32(500)
buf := make([]byte, 4)
binary.BigEndian.PutUint32(buf, v)

// read
x := binary.BigEndian.Uint32(buf)




原文地址:https://www.cnblogs.com/ldms/p/11320863.html