package main import ( "fmt" "encoding/binary" ) func main() { // // Largest signed int64 in smallest byte slice. // var signedInt64 int64 = 9223372036854775807 a := make([]byte, 10) binary.PutVarint(a, signedInt64) decodedSignedInt64, _ := binary.Varint(a) fmt.Println(a, decodedSignedInt64) // // Largest unsigned int64 in smallest byte slice. // var unsignedInt64 uint64 = 18446744073709551615 b := make([]byte, 10) binary.PutUvarint(b, unsignedInt64) decodedUnsignedInt64, _ := binary.Uvarint(b) fmt.Println(b, decodedUnsignedInt64) } // Output: // [254 255 255 255 255 255 255 255 255 1] 9223372036854775807 // [255 255 255 255 255 255 255 255 255 1] 18446744073709551615