converters

package
v3.0.0-beta13 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB map[string]Converter
)

Functions

func DurationWithDefaultMinMax

func DurationWithDefaultMinMax(s *string, defaultD, minD, maxD time.Duration) (time.Duration, error)

DurationWithDefaultMinMax parses a duration string and clamps the result within minD and maxD or returns defaultD. If s is nil or empty, defaultD is returned, clamped within the range defined by minD and maxD.

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

func ReadFile

func ReadFile(fs embed.FS, s string) string

func Register

func Register(c Converter)

Types

type Converter

type Converter interface {
	Convert(s string) (any, error)
	String() string
}

func Lookup

func Lookup(s string) Converter

type TBool

type TBool struct{}

func (TBool) Convert

func (t TBool) Convert(s string) (any, error)

func (TBool) String

func (t TBool) String() string

type TDuration

type TDuration struct{}

func (TDuration) Convert

func (t TDuration) Convert(s string) (any, error)

Convert converts duration string to *time.Duration

nil is returned when duration is unset Default unit is second when not specified

func (TDuration) String

func (t TDuration) String() string

type TFileMode

type TFileMode struct{}

func (TFileMode) Convert

func (t TFileMode) Convert(s string) (any, error)

func (TFileMode) String

func (t TFileMode) String() string

type TFloat64

type TFloat64 struct{}

func (TFloat64) Convert

func (t TFloat64) Convert(s string) (any, error)

func (TFloat64) String

func (t TFloat64) String() string

type TGroup

type TGroup struct{}

func (TGroup) Convert

func (t TGroup) Convert(s string) (interface{}, error)

func (TGroup) String

func (t TGroup) String() string

type TInt

type TInt struct{}

func (TInt) Convert

func (t TInt) Convert(s string) (any, error)

func (TInt) String

func (t TInt) String() string

type TInt64

type TInt64 struct{}

func (TInt64) Convert

func (t TInt64) Convert(s string) (any, error)

func (TInt64) String

func (t TInt64) String() string

type TList

type TList struct{}

func (TList) Convert

func (t TList) Convert(s string) (any, error)

func (TList) String

func (t TList) String() string

type TListLowercase

type TListLowercase struct{}

func (TListLowercase) Convert

func (t TListLowercase) Convert(s string) (any, error)

func (TListLowercase) String

func (t TListLowercase) String() string

type TSet

type TSet struct{}

func (TSet) Convert

func (t TSet) Convert(s string) (any, error)

func (TSet) String

func (t TSet) String() string

type TShlex

type TShlex struct{}

func (TShlex) Convert

func (t TShlex) Convert(s string) (any, error)

func (TShlex) String

func (t TShlex) String() string

type TSize

type TSize struct{}

func (TSize) Convert

func (t TSize) Convert(s string) (any, error)

func (TSize) String

func (t TSize) String() string

type TString

type TString struct{}

func (TString) Convert

func (t TString) Convert(s string) (any, error)

func (TString) String

func (t TString) String() string

type TTristate

type TTristate struct{}

func (TTristate) Convert

func (t TTristate) Convert(s string) (any, error)

func (TTristate) String

func (t TTristate) String() string

type TUmask

type TUmask struct{}

func (TUmask) Convert

func (t TUmask) Convert(s string) (any, error)

func (TUmask) String

func (t TUmask) String() string

type TUser

type TUser struct{}

func (TUser) Convert

func (t TUser) Convert(s string) (interface{}, error)

func (TUser) String

func (t TUser) String() string

Jump to

Keyboard shortcuts

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