Standard library / fmt
fmt.Append()
Appends formatted bytes to the destination slice b and returns the resulting slice; retain the returned value because growth can allocate. Default-formatted values, with spaces between adjacent non-string operands. Expected stdout: '"id:2 3"\n'.
Formal Syntax & Structure
go syntaxgo
func Append(b []byte, a ...any) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| b | []byte | Destination byte slice; existing prefix is preserved. |
| a | ...any | Values consumed by formatting; may be empty. |
Return Value
[]byte
Formatted bytes including the original prefix.
Working Example
Example Snippetgo
package main
import ( "fmt")
func main() { b := []byte("id:") b = fmt.Append(b, 2, 3) fmt.Printf("%q\n", b)}