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
+12.3k Golang : Display list of countries and ISO codes
+8k Golang : Handle Palindrome string with case sensitivity and unicode
+24k Golang : Call function from another package
+10.4k Golang : Generate random integer or float number
+47.8k Golang : Convert int to byte array([]byte)
+9.4k Golang : Web(Javascript) to server-side websocket example
+5.4k Python : Delay with time.sleep() function example
+26.4k Golang : Convert(cast) string to uint8 type and back to string
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+8.9k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+15.3k Golang : Get query string value on a POST request
+8.2k Golang : Routes multiplexer routing example with regular expression control