Go uint64 转化成byte数组

Go uint64 转化成byte数组

go中将uint64 转化成byte数组

i := uint64(123456789)

fmt.Println(i)

b := make([]byte, 8)
binary.BigEndian.PutUint64(b, i)

fmt.Println(b[:])

i = uint64(binary.BigEndian.Uint64(b))

java 中读取byte数组成long

Java 默认采用高字节序

 byte[] len = new byte[]{0 ,0 ,0 ,0, 7, 91, (byte)205, 21};
 ByteBuffer bb = ByteBuffer.wrap(len);
 System.out.println(bb.getLong());

你可能感兴趣的:(code,golang)