Created
July 1, 2017 20:32
-
-
Save awnumar/f876bbedd4b014ce858c04d879ed9ef5 to your computer and use it in GitHub Desktop.
Revisions
-
Awn created this gist
Jul 1, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ 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