Documentation ¶
Index ¶
- type Config
- func (c *Config) Add(section string, key string, value string)
- func (c *Config) Del(section string, key string)
- func (c *Config) Filename() string
- func (c *Config) Get(section string, key string) string
- func (c *Config) Read() error
- func (c *Config) Reset()
- func (c *Config) Set(section string, key string, value string)
- func (c *Config) SetFilename(filename string)
- func (c *Config) Write() error
- func (c *Config) WriteTo(filename string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.1.1
type Config struct {
// contains filtered or unexported fields
}
Config struct constructs a new configuration handler.
func NewConfig ¶ added in v0.1.1
NewConfig function cnstructs a new Config struct with filename. You have to call Read() function to let it read from the file. Otherwise you will get empty string (i.e., "") when you are calling Get() function. Another usage is that you call NewConfig() function and then call Add()/Set() function to add new key-values to the configuration. Finally you can call Write() function to write the new configuration to the file.
func (*Config) Add ¶ added in v0.1.1
Add function adds a new key to the configuration. Function Add() is exactly the same as function Set().
func (*Config) Filename ¶ added in v0.1.1
Filename function returns the filename of the configuration.
func (*Config) Get ¶ added in v0.1.1
Get function returns the value of a key in the configuration. If the key does not exist, it returns empty string (i.e., "").
func (*Config) Read ¶ added in v0.1.1
Read function reads configurations from the file defined in Config.filename.
func (*Config) Reset ¶ added in v0.1.1
func (c *Config) Reset()
Reset function reset the map in the configuration.
func (*Config) Set ¶ added in v0.1.1
Set function updates the value of a key in the configuration. Function Set() is exactly the same as function Add().
func (*Config) SetFilename ¶ added in v0.1.1
SetFilename function sets the filename of the configuration.