Documentation ¶
Index ¶
- func DecodeToml(fileName string, v interface{}) error
- func EncodeToml(fileName string, v interface{}) error
- func LoadConfig(cfgPath, defaultCfgPath string, v interface{}) error
- func WriteConfig(fileName, content string) error
- type Duration
- func (d Duration) Duration() time.Duration
- func (d *Duration) MarshalJSON() (data []byte, err error)
- func (d Duration) MarshalText() (text []byte, err error)
- func (d Duration) String() string
- func (d *Duration) UnmarshalJSON(data []byte) (err error)
- func (d *Duration) UnmarshalText(text []byte) error
- type Size
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeToml ¶
DecodeToml decodes data from file using toml format
func EncodeToml ¶
EncodeToml encodes data into file using toml format, encode data to tmp file, if success then rename tmp => target file
func LoadConfig ¶
LoadConfig loads config from file, if fail return err
func WriteConfig ¶
Types ¶
type Duration ¶
Duration is a TOML wrapper type for time.Duration.
func (*Duration) MarshalJSON ¶
MarshalJSON converts a duration to a string for decoding json
func (Duration) MarshalText ¶
MarshalText converts a duration to a string for decoding toml
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON parses a JSON value into a duration value.
func (*Duration) UnmarshalText ¶
UnmarshalText parses a TOML value into a duration value. See https://github.com/BurntSushi/toml
type Size ¶
type Size uint64
Size is a TOML wrapper type for size k/K -> KB, m/M -> MB, g/G -> GB
func (*Size) MarshalJSON ¶
MarshalJSON converts a size to a human readable size
func (*Size) MarshalText ¶
MarshalText converts a size to a string for decoding toml
func (*Size) UnmarshalJSON ¶
UnmarshalJSON parses a JSON value into a size value.
func (*Size) UnmarshalText ¶
UnmarshalText parses a byte size from text.