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) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| dst | []byte | Destination byte slice; existing prefix is preserved. |
| i | int64 | Integer value to encode. |
| base | int | Output 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))}