Standard library / net/netip
netip.Addr.AppendTo()
Append textual representation to an existing byte slice. Expected stdout: 'value=192.0.2.7\n'.
Formal Syntax & Structure
go syntaxgo
func (ip Addr) AppendTo(b []byte) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| b | []byte | Byte buffer, binary representation or prefix length as indicated by its type. |
Return Value
[]byte
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net/netip")
func main() { fmt.Println(string(netip.MustParseAddr("192.0.2.7").AppendTo([]byte("value=")))) }
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}