Documentation
¶
Index ¶
- func AllowOnly[T any](format func(T) string, allowed []T) func(T) error
- func FormatBytes(b uint64) string
- func FormatFile(f *os.File) string
- func FormatFloat32(f float32) string
- func FormatFloat64(f float64) string
- func FormatIP(ip net.IP) string
- func FormatIPv4Mask(ip net.IPMask) string
- func FormatList[T any](format func(T) string, values []T) []string
- func FormatString(s string) string
- func FormatTCPAddr(addr *net.TCPAddr) string
- func FormatTime(t time.Time) string
- func JoinFormatted[T any](values []T, format func(T) string) string
- func ParseBytes(s string) (uint64, error)
- func ParseFile(s string) (*os.File, error)
- func ParseFloat32(s string) (float32, error)
- func ParseFloat64(s string) (float64, error)
- func ParseIP(s string) (net.IP, error)
- func ParseIPv4Mask(s string) (net.IPMask, error)
- func ParseString(s string) (string, error)
- func ParseTCPAddr(s string) (*net.TCPAddr, error)
- func ParseTime(s string) (time.Time, error)
- func PluralSuffix(i int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowOnly ¶ added in v0.0.19
AllowOnly returns a validator function that permits only values from the given list. Each value is compared using the provided formatting function. The format function is used to normalize or stringify values for comparison, which is useful for case-insensitive or structured types.
func FormatList ¶ added in v0.0.19
FormatList applies the given format function to each element of the slice and returns a new slice of formatted strings. This is useful for preparing human-readable output from a slice of structured types.
func FormatTCPAddr ¶
FormatTCPAddr *net.TCPAddr → string
func JoinFormatted ¶ added in v0.0.19
JoinFormatted applies the given format function to each value and joins them with commas. If format is nil, it falls back to using fmt.Sprintf("%v", values).
func ParseFloat64 ¶
ParseDuration string → time.Duration
func ParseIPv4Mask ¶
ParseIPv4Mask string → net.IPMask
func ParseTCPAddr ¶
ParseTCPAddr string → *net.TCPAddr
func PluralSuffix ¶
PluralSuffix returns "s" if the given number is not 1, otherwise it returns an empty string. It is useful for constructing basic pluralized words like "flag" or "flags".
Types ¶
This section is empty.