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 ¶
type Config struct {
// contains filtered or unexported fields
}
Config struct constructs a new configuration handler.
func NewConfig ¶
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 ¶
Add function adds a new key to the configuration. Function Add() is exactly the same as function Set().
func (*Config) Get ¶
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) Set ¶
Set function updates the value of a key in the configuration. Function Set() is exactly the same as function Add().
func (*Config) SetFilename ¶
SetFilename function sets the filename of the configuration.