value

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanParseType

func CanParseType(t reflect.Type) bool

CanParseType returns true if the specified type has a registered value parser, implements to flag.Value interface or implements encoding.TextUnmarshaler interface.

func Parse

func Parse(v interface{}, s string) error

Parse converts a string into an actual value, using a string conversion function specific to the target type. `v` must be a non-nil pointer to a variable to parse into, and panics otherwise. Types with a registered parser function, including all common primitive types are converted using that parser function. Types that conform to the flag.Value interface are converted with the Set() method. Types that conform to the encoding.TextUnmarshaler interface are converted using the UnmarshalText() method. The function panics if the target ype is not parsable.

func RegisterParser

func RegisterParser(parsers ...interface{})

RegisterParser registers a function of type 'func(string) (T, error)' as value parser for type T

Types

This section is empty.

Jump to

Keyboard shortcuts

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