Documentation ¶
Overview ¶
Package shconf implements a parser and scanner for the configuration in format shell-variable.
The configuration file consists on entries with the format "key" [separator] "value". The comments are indicated by "#" at the beginning of a line and upon the keys.
Index ¶
- Variables
- type Config
- func (c *Config) Get(key string) (string, error)
- func (c *Config) Getbool(key string) (bool, error)
- func (c *Config) Getfloat(key string) (float64, error)
- func (c *Config) Getint(key string) (int, error)
- func (c *Config) Getuint(key string) (uint, error)
- func (c *Config) Print()
- func (c *Config) Separator() []byte
- func (c *Config) Set(key, value string) error
- func (c *Config) Unmarshal(out interface{}) error
- type Option
- type Scanner
- type TypeError
Constants ¶
This section is empty.
Variables ¶
var ( ErrKey = errors.New("key not found") ErrStructPtr = errors.New("argument must be a pointer to struct") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
A Config represents the configuration.
func ParseFile ¶
ParseFile creates a new Config and parses the file configuration from the named file.
func (*Config) Separator ¶
Separator returns the character/s used to separate the key from the value.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner provides a convenient interface for reading data such as a file of lines of text in format key-value. Successive calls to the Scan method will step through the 'tokens' of a file, skipping the bytes between the tokens.
Scanning stops unrecoverably at EOF, the first I/O error, or a token too large to fit in the buffer.
func NewScanner ¶
NewScanner returns a new Scanner to read from r, with the option to skip the keys disabled.
func (*Scanner) Bytes ¶
Bytes returns the most recents tokens generated by a call to Scan. The underlying array may point to data that will be overwritten by a subsequent call to Scan. It does no allocation.
func (*Scanner) Scan ¶
Scan advances the Scanner to the next tokens, which will then be available through the Bytes or Text method. It returns false when the scan stops, either by reaching the end of the input or an error. After Scan returns false, the Err method will return any error that occurred during scanning, except that if it was io.EOF, Err will return nil.