config

package
v0.0.0-...-51c1140 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package config implements configuration file parsing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseFile

func ParseFile(name string, v interface{}) error

ParseFile parses the configuration in the file specified by name and stores the result in the value pointed to by v.

func ParseString

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

ParseString parses the configuration in s and stores the result in the value pointed to by v.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

A Decoder represents a configuration parser reading a particular input stream. The parser assumes that its input is encoded in UTF-8.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder creates a new configuration parser reading from r.

func (*Decoder) Decode

func (d *Decoder) Decode(v interface{}) (err error)

Decode parses the configuration and stores the result in the value pointed to by v.

Decode implements the following PEG.

INI = ((KEYWORD WS* '=' WS* VALUE) / COMMENT / WS)* KEYWORD = ALPHA (ALPHA / NUMERIC / '_' / '.')* VALUE = QUOTED / DQUOTED / RAW QUOTED = '\” .* '\” DQUOTED = '"' .* '"' RAW = .* EOL COMMENT = ('#' / ';') .* EOL

type FlagParserShim

type FlagParserShim struct {
	// contains filtered or unexported fields
}

FlagParserShim is a flag.Value that unmarshals flag values using ParseString()

func NewFlagParserShim

func NewFlagParserShim(v interface{}) *FlagParserShim

NewFlagParserShim creates a FlagParserShim from a pointer.

func (*FlagParserShim) Set

func (cv *FlagParserShim) Set(s string) error

Set parses a configuration setting value.

func (*FlagParserShim) String

func (cv *FlagParserShim) String() string

String always returns an empty string. It's implemented to satisfy the flag.Value interface.

type Timeout

type Timeout int64

A Timeout specifies a time limit as a non-negative int64 nanosecond count. The representation limits the largest representable time limit to approximately 290 years.

func (Timeout) String

func (t Timeout) String() string

String returns a string representing the timeout in the form "72h3m0.5s". Leading zero units are omitted. As a special case, durations less than one second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure that the leading digit is non-zero. The zero duration formats as 0s.

func (*Timeout) UnmarshalText

func (t *Timeout) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The timeout is expected to be non-negative. Terms without a unit are interpreted as seconds.

Jump to

Keyboard shortcuts

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