Documentation ¶
Overview ¶
The Tideland Go Library stringex package helps when working with strings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PackageVersion ¶
PackageVersion returns the version of the version package.
Types ¶
type Defaulter ¶
type Defaulter interface { fmt.Stringer // AsString returns the value itself, only an error will // return the default. AsString(v Valuer, dv string) string // AsStringSlice returns the value as slice of strings // separated by the passed seperator. AsStringSlice(v Valuer, sep string, dv []string) []string // AsStringMap returns the value as map of strings to strings. // The rows are seperated by the rsep, the key/values per // row with kvsep. AsStringMap(v Valuer, rsep, kvsep string, dv map[string]string) map[string]string // AsBool returns the value interpreted as bool. Here the // strings 1, t, T, TRUE, true, True are interpreted as // true, the strings 0, f, F, FALSE, false, False as false. AsBool(v Valuer, dv bool) bool // AsInt returns the value interpreted as int. AsInt(v Valuer, dv int) int // AsInt64 returns the value interpreted as int64. AsInt64(v Valuer, dv int64) int64 // AsUint returns the value interpreted as uint. AsUint(v Valuer, dv uint) uint // AsUint64 returns the value interpreted as uint64. AsUint64(v Valuer, dv uint64) uint64 // AsFloat64 returns the value interpreted as float64. AsFloat64(v Valuer, dv float64) float64 // AsTime returns the value interpreted as time in // the given layout. AsTime(v Valuer, layout string, dv time.Time) time.Time // AsDuration returns the value interpreted as duration. AsDuration(v Valuer, dv time.Duration) time.Duration }
Defaulter provides an access to valuers interpreting the strings as types. In case of access or conversion errors these errors will be logged and the passed default values are returned.
func NewDefaulter ¶
NewDefaulter creates a defaulter with the given settings.
Click to show internal directories.
Click to hide internal directories.