txtutil

package
v5.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeQuoted

func EncodeQuoted(t string) string

EncodeQuoted encodes a string into a series of quoted 255-octet chunks. That is, when decoded each chunk would be 255-octets with the remainder in the last chunk.

The output looks like:

`""`                                      empty
`"255\"octets"`                           quotes are escaped
`"255\\octets"`                           backslashes are escaped
`"255octets" "255octets" "remainder"`     long strings are chunked

func EncodeSingle

func EncodeSingle(t string) string

EncodeSingle encodes a string as a single quoted value without splitting into 255-octet chunks. This is intended for user-facing display (e.g., diff preview) where the chunked representation is confusing.

func Extend

func Extend(host, zone string) string

func ParseQuoted

func ParseQuoted(s string) (string, error)

ParseQuoted parses a string of RFC1035-style quoted items. The resulting items are then joined into one string. This is useful for parsing TXT records. Examples: `foo` => foo `"foo"` => foo `"f\"oo"` => f"oo `"f\\oo"` => f\oo `"foo" "bar"` => foobar `"foo" bar` => foobar.

func StripZone

func StripZone(label, zone string) string

func ToChunks

func ToChunks(s string) []string

ToChunks returns the string as chunks of 255-octet strings (the last string being the remainder).

func Zoneify

func Zoneify(txts []string) string

Zoneify is like ZoneifyQuoted, but omits the quotes when not needed. (Note: It might quote things that don't strictly need quoting, but it won't fail to quote things that do need quoting.) Example: []string{"one", "tw o", "three"} outputs: `one "tw o" three`.

func ZoneifyManyAny

func ZoneifyManyAny(args []any) string

ZoneifyManyAny is a convenience function for Zoneify when you have a []any and want a string.

func ZoneifyQuoted

func ZoneifyQuoted(txts []string) string

ZoneifyQuoted prints strings, each individually quoted and escaped, as used by Txt records. This is useful for spewing untrusted data into a zonefile, or URLs and other things that private types might want to use. Example: []string{"one", "tw o", "three"} outputs: `"one" "tw o" "three"`.

func ZoneifyString

func ZoneifyString(s string) string

ZoneifyString is a convenience function for Zoneify when you have only one string.

func ZoneifyStringQuoted

func ZoneifyStringQuoted(s string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL