parse

package
Version: v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2018 License: MIT Imports: 7 Imported by: 106

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadParsers

func LoadParsers(customParsers map[reflect.Type]Parser) (map[reflect.Type]Parser, error)

LoadParsers loads default parsers and custom parsers given as parameter. Return a map [reflect.Type]parsers bool, int, int64, uint, uint64, float64,

Types

type BoolFlag

type BoolFlag interface {
	flag.Value
	IsBoolFlag() bool
}

BoolFlag optional interface to indicate boolean flags that can be supplied without "=value" text

type BoolValue

type BoolValue bool

BoolValue bool Value type

func (*BoolValue) Get

func (b *BoolValue) Get() interface{}

Get returns the bool value.

func (*BoolValue) IsBoolFlag

func (b *BoolValue) IsBoolFlag() bool

IsBoolFlag return true

func (*BoolValue) Set

func (b *BoolValue) Set(s string) error

Set sets bool value from the given string value.

func (*BoolValue) SetValue

func (b *BoolValue) SetValue(val interface{})

SetValue sets the duration from the given bool-asserted value.

func (*BoolValue) String

func (b *BoolValue) String() string

type Duration

type Duration time.Duration

Duration is a custom type suitable for parsing duration values. It supports `time.ParseDuration`-compatible values and suffix-less digits; in the latter case, seconds are assumed.

func (*Duration) Get

func (d *Duration) Get() interface{}

Get returns the duration value.

func (*Duration) MarshalJSON added in v1.1.2

func (d *Duration) MarshalJSON() ([]byte, error)

MarshalJSON serializes the given duration value.

func (*Duration) MarshalText added in v1.1.1

func (d *Duration) MarshalText() ([]byte, error)

MarshalText serialize the given duration value into a text.

func (*Duration) Set

func (d *Duration) Set(s string) error

Set sets the duration from the given string value.

func (*Duration) SetValue

func (d *Duration) SetValue(val interface{})

SetValue sets the duration from the given Duration-asserted value.

func (*Duration) String

func (d *Duration) String() string

String returns a string representation of the duration value.

func (*Duration) UnmarshalJSON added in v1.1.1

func (d *Duration) UnmarshalJSON(text []byte) error

UnmarshalJSON deserializes the given text into a duration value.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText deserializes the given text into a duration value. It is meant to support TOML decoding of durations.

type Float64Value

type Float64Value float64

Float64Value float64 Value

func (*Float64Value) Get

func (f *Float64Value) Get() interface{}

Get returns the float64 value.

func (*Float64Value) Set

func (f *Float64Value) Set(s string) error

Set sets float64 value from the given string value.

func (*Float64Value) SetValue

func (f *Float64Value) SetValue(val interface{})

SetValue sets the Float64Value from the given float64-asserted value.

func (*Float64Value) String

func (f *Float64Value) String() string

type Int64Value

type Int64Value int64

Int64Value int64 Value

func (*Int64Value) Get

func (i *Int64Value) Get() interface{}

Get returns the int64 value.

func (*Int64Value) Set

func (i *Int64Value) Set(s string) error

Set sets int64 value from the given string value.

func (*Int64Value) SetValue

func (i *Int64Value) SetValue(val interface{})

SetValue sets the Int64Value from the given int64-asserted value.

func (*Int64Value) String

func (i *Int64Value) String() string

type IntValue

type IntValue int

IntValue int Value

func (*IntValue) Get

func (i *IntValue) Get() interface{}

Get returns the int value.

func (*IntValue) Set

func (i *IntValue) Set(s string) error

Set sets int value from the given string value.

func (*IntValue) SetValue

func (i *IntValue) SetValue(val interface{})

SetValue sets the IntValue from the given int-asserted value.

func (*IntValue) String

func (i *IntValue) String() string

type Parser

type Parser interface {
	flag.Getter
	SetValue(interface{})
}

Parser is an interface that allows the contents of a flag.Getter to be set.

type SliceStrings

type SliceStrings []string

SliceStrings parse slice of strings

func (*SliceStrings) Get

func (s *SliceStrings) Get() interface{}

Get []string

func (*SliceStrings) Set

func (s *SliceStrings) Set(str string) error

Set adds strings elem into the the parser. It splits str on , and ;

func (*SliceStrings) SetValue

func (s *SliceStrings) SetValue(val interface{})

SetValue sets []string into the parser

func (*SliceStrings) String

func (s *SliceStrings) String() string

String return slice in a string

type StringValue

type StringValue string

StringValue string Value

func (*StringValue) Get

func (s *StringValue) Get() interface{}

Get returns the string value.

func (*StringValue) Set

func (s *StringValue) Set(val string) error

Set sets string value from the given string value.

func (*StringValue) SetValue

func (s *StringValue) SetValue(val interface{})

SetValue sets the StringValue from the given string-asserted value.

func (*StringValue) String

func (s *StringValue) String() string

type TimeValue

type TimeValue time.Time

TimeValue time.Time Value

func (*TimeValue) Get

func (t *TimeValue) Get() interface{}

Get returns the time.Time value.

func (*TimeValue) Set

func (t *TimeValue) Set(s string) error

Set sets time.Time value from the given string value.

func (*TimeValue) SetValue

func (t *TimeValue) SetValue(val interface{})

SetValue sets the TimeValue from the given time.Time-asserted value.

func (*TimeValue) String

func (t *TimeValue) String() string

type Uint64Value

type Uint64Value uint64

Uint64Value uint64 Value

func (*Uint64Value) Get

func (i *Uint64Value) Get() interface{}

Get returns the uint64 value.

func (*Uint64Value) Set

func (i *Uint64Value) Set(s string) error

Set sets uint64 value from the given string value.

func (*Uint64Value) SetValue

func (i *Uint64Value) SetValue(val interface{})

SetValue sets the Uint64Value from the given uint64-asserted value.

func (*Uint64Value) String

func (i *Uint64Value) String() string

type UintValue

type UintValue uint

UintValue uint Value

func (*UintValue) Get

func (i *UintValue) Get() interface{}

Get returns the uint value.

func (*UintValue) Set

func (i *UintValue) Set(s string) error

Set sets uint value from the given string value.

func (*UintValue) SetValue

func (i *UintValue) SetValue(val interface{})

SetValue sets the UintValue from the given uint-asserted value.

func (*UintValue) String

func (i *UintValue) String() string

Source Files

Jump to

Keyboard shortcuts

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