ltoml

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeToml

func DecodeToml(fileName string, v interface{}) error

DecodeToml decodes data from file using toml format

func EncodeToml

func EncodeToml(fileName string, v interface{}) error

EncodeToml encodes data into file using toml format, encode data to tmp file, if success then rename tmp => target file

func LoadConfig

func LoadConfig(cfgPath, defaultCfgPath string, v interface{}) error

LoadConfig loads config from file, if fail return err

func WriteConfig

func WriteConfig(fileName, content string) error

Types

type Duration

type Duration time.Duration

Duration is a TOML wrapper type for time.Duration.

func (Duration) Duration

func (d Duration) Duration() time.Duration

Duration returns the standard time.Duration

func (*Duration) MarshalJSON

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

MarshalJSON converts a duration to a string for decoding json

func (Duration) MarshalText

func (d Duration) MarshalText() (text []byte, err error)

MarshalText converts a duration to a string for decoding toml

func (Duration) String

func (d Duration) String() string

String returns the string representation of the duration.

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON parses a JSON value into a duration value.

func (*Duration) UnmarshalText

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

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

func (s *Size) MarshalJSON() (data []byte, err error)

MarshalJSON converts a size to a human readable size

func (*Size) MarshalText

func (s *Size) MarshalText() (text []byte, err error)

MarshalText converts a size to a string for decoding toml

func (Size) String

func (s Size) String() string

String returns the string representation of the size.

func (*Size) UnmarshalJSON

func (s *Size) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON parses a JSON value into a size value.

func (*Size) UnmarshalText

func (s *Size) UnmarshalText(text []byte) error

UnmarshalText parses a byte size from text.

Jump to

Keyboard shortcuts

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