斯蒂芬大帝
例如,package mainimport "fmt"func readUIntLE(buf []byte, offset, byteLength int) uint64 { var n uint64 buf = buf[offset : offset+byteLength] if len(buf) > 8 { buf = buf[:8] } for i, b := range buf { n += uint64(b) << uint(8*i) } return n}func main() { buf := []byte{2, 4, 8, 16, 32, 64, 128, 255} fmt.Println(buf) fmt.Println(readUIntLE(buf, 0, 4)) fmt.Println(readUIntLE(buf, 0, len(buf))) fmt.Println(readUIntLE(buf, len(buf)-1, 1))}输出:[2 4 8 16 32 64 128 255]26896077018410785783142679554255