format

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatStringLike

func FormatStringLike(typeName string, sp fspec.FormatSpec, raw string, byteUnits bool) (string, error)

FormatStringLike implements the shared rendering for `string`, `runes` and `bytes` per the format mini-language.

raw — the underlying text payload. byteUnits — true for `bytes` (precision counts bytes), false for `string` / `runes` (precision counts runes).

Recognized verbs: empty/'s' raw text; 'v' source form; 'q' Kavun-quoted string; 'b' / 'B' standard / URL-safe base64; 'x' / 'X' lower / upper hex of the underlying bytes; 'u' percent-encoded URL component (RFC 3986 unreserved set).

Sign / Grouping / ZeroPad / CoerceZero are parse errors. Precision truncates the source before encoding. Default alignment is AlignLeft. Verb 'v' must be processed by caller.

func PercentEncodeComponent

func PercentEncodeComponent(s string) string

PercentEncodeComponent encodes s as an RFC 3986 URL component: bytes outside the unreserved set (A-Z / a-z / 0-9 / '-' / '_' / '.' / '~') are percent-encoded. Equivalent to JavaScript's encodeURIComponent.

func ValidateContainerSpec

func ValidateContainerSpec(typeName string, sp fspec.FormatSpec) error

ValidateContainerSpec rejects fields that have no meaning for container types. Containers accept only the empty verb plus width / fill / align. The 'v' verb is dispatched separately by each container's Format method.

Types

This section is empty.

Jump to

Keyboard shortcuts

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