Documentation ¶
Index ¶
- Constants
- type Config
- func (self *Config) AddOption(section string, option string, value string) bool
- func (self *Config) AddSection(section string) bool
- func (self *Config) Bool(section string, option string) (value bool, err error)
- func (self *Config) Float(section string, option string) (value float64, err error)
- func (self *Config) HasOption(section string, option string) bool
- func (self *Config) HasSection(section string) bool
- func (self *Config) Int(section string, option string) (value int, err error)
- func (self *Config) Options(section string) (options []string, err error)
- func (self *Config) RawString(section string, option string) (value string, err error)
- func (self *Config) RemoveOption(section string, option string) bool
- func (self *Config) RemoveSection(section string) bool
- func (self *Config) Sections() (sections []string)
- func (self *Config) String(section string, option string) (value string, err error)
- func (self *Config) WriteFile(fname string, perm os.FileMode, header string) error
Constants ¶
const ( DEFAULT_COMMENT = "# " ALTERNATIVE_COMMENT = "; " DEFAULT_SEPARATOR = ":" ALTERNATIVE_SEPARATOR = "=" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is the representation of configuration settings.
func New ¶
New creates an empty configuration representation. This representation can be filled with AddSection and AddOption and then saved to a file using WriteFile.
=== Arguments
comment: has to be `DEFAULT_COMMENT` or `ALTERNATIVE_COMMENT` separator: has to be `DEFAULT_SEPARATOR` or `ALTERNATIVE_SEPARATOR` preSpace: indicate if is inserted a space before of the separator postSpace: indicate if is added a space after of the separator
func NewDefault ¶
func NewDefault() *Config
NewDefault creates a configuration representation with values by default.
func Read ¶
ReadDefault reads a configuration file and returns its representation. All arguments, except `fname`, are related to `New()`
func ReadDefault ¶
ReadDefault reads a configuration file and returns its representation. It uses values by default.
func (*Config) AddOption ¶
AddOption adds a new option and value to the configuration.
If the section is nil then uses the section by default; if it does not exist, it is created in advance.
It returns true if the option and value were inserted, and false if the value was overwritten.
func (*Config) AddSection ¶
AddSection adds a new section to the configuration.
If the section is nil then uses the section by default which it's already created.
It returns true if the new section was inserted, and false if the section already existed.
func (*Config) Bool ¶
Bool has the same behaviour as String but converts the response to bool. See "boolString" for string values converted to bool.
func (*Config) HasOption ¶
HasOption checks if the configuration has the given option in the section. It returns false if either the option or section do not exist.
func (*Config) HasSection ¶
HasSection checks if the configuration has the given section. (The default section always exists.)
func (*Config) Options ¶
Options returns the list of options available in the given section. It returns an error if the section does not exist and an empty list if the section is empty. Options within the default section are also included.
func (*Config) RawString ¶
RawString gets the (raw) string value for the given option in the section. The raw string value is not subjected to unfolding, which was illustrated in the beginning of this documentation.
It returns an error if either the section or the option do not exist.
func (*Config) RemoveOption ¶
RemoveOption removes a option and value from the configuration. It returns true if the option and value were removed, and false otherwise, including if the section did not exist.
func (*Config) RemoveSection ¶
RemoveSection removes a section from the configuration. It returns true if the section was removed, and false if section did not exist.
func (*Config) Sections ¶
Sections returns the list of sections in the configuration. (The default section always exists.)
func (*Config) String ¶
String gets the string value for the given option in the section. If the value needs to be unfolded (see e.g. %(host)s example in the beginning of this documentation), then String does this unfolding automatically, up to _DEPTH_VALUES number of iterations.
It returns an error if either the section or the option do not exist, or the unfolding cycled.