Standard library / encoding/binary
encoding/binary.AppendUvarint()
Appends an unsigned variable-length integer; smaller values use fewer bytes. Expected stdout: 'ffac02\n'.
Formal Syntax & Structure
go syntaxgo
func AppendUvarint(buf []byte, x uint64) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| buf | []byte | Byte buffer used for the operation; append APIs extend it. |
| x | uint64 | Integer value to encode, or length for DecodedLen. |
Return Value
[]byte
Resulting byte slice.
Working Example
Example Snippetgo
package main
import ( "encoding/binary" "fmt")
func must(e error) { if e != nil { panic(e) }}
func main() { fmt.Printf("%x\n", binary.AppendUvarint([]byte{0xff}, 300)) }