Standard library / strconv

strconv.AppendInt()

Appends signed integer in base 2–36 to dst. Returns the expanded slice; retain it even if the initial destination has enough capacity. Expected stdout: 'v=-1f\n'.

Formal Syntax & Structure

go syntaxgo
func AppendInt(dst []byte, i int64, base int) []byte

Parameters & Attributes

NameTypeDescription
dst[]byteDestination byte slice; existing prefix is preserved.
iint64Integer value to encode.
baseintOutput radix 2–36.

Return Value

[]byte

Resulting byte slice, including original prefix.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strconv")
func main() {  b := []byte("v=")  b = strconv.AppendInt(b, -31, 16)  fmt.Println(string(b))}
Go Reference