代码如下:
import encoding/binary
func uInt32ToBytes(i uint32) []byte {
var buf = make([]byte, 4)
binary.LittleEndian.PutUint32(buf, i)
return buf
}
func bytesToUInt32(buf []byte) uint32 {
return binary.LittleEndian.Uint32(buf)
}
代码如下:
import encoding/binary
func uInt32ToBytes(i uint32) []byte {
var buf = make([]byte, 4)
binary.LittleEndian.PutUint32(buf, i)
return buf
}
func bytesToUInt32(buf []byte) uint32 {
return binary.LittleEndian.Uint32(buf)
}