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
+23.5k Golang : Get ASCII code from a key press(cross-platform) example
+14.2k Golang : syscall.Socket example
+11.1k Golang : Web routing/multiplex example
+8.3k Golang : Count leading or ending zeros(any item of interest) example
+6.9k Golang : How to solve "too many .rsrc sections" error?
+12.7k Golang : zlib compress file example
+26.6k Golang : Encrypt and decrypt data with AES crypto
+7.9k Setting $GOPATH environment variable for Unix/Linux and Windows
+10.1k Golang : Compare files modify date example
+10.6k Golang : ISO8601 Duration Parser example
+6.7k Golang : When to use make or new?
+8.2k Golang : Routes multiplexer routing example with regular expression control