Golang encoding/binary.PutUvarint() function example
package encoding/binary
PutUvarint encodes a uint64 into buf(1st parameter) and returns the number of bytes written. If the buffer is too small, PutUvarint will panic.
Golang encoding/binary.PutUvarint() function usage example
func encodeBlockHandle(dst []byte, b blockHandle) int {
n := binary.PutUvarint(dst, b.offset)
m := binary.PutUvarint(dst[n:], b.length)
return n + m
}
References :
http://golang.org/pkg/encoding/binary/#PutUvarint
https://github.com/syndtr/goleveldb/blob/master/leveldb/table/table.go
Advertisement
Something interesting
Tutorials
+7.9k Setting $GOPATH environment variable for Unix/Linux and Windows
+18.7k Unmarshal/Load CSV record into struct in Go
+7.4k Golang : Hue, Saturation and Value(HSV) with OpenCV example
+13.5k Golang : How to get year, month and day?
+5.1k Swift : Convert (cast) Float to Int or Int32 value
+8.7k Golang : How to join strings?
+31.5k Golang : bufio.NewReader.ReadLine to read file line by line
+11.5k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+15.6k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+26k Golang : Convert IP address string to long ( unsigned 32-bit integer )
+13.6k Golang : reCAPTCHA example
+13.4k Golang : Increment string example