This section is empty.


This section is empty.


This section is empty.


type Config

type Config struct {
	// contains filtered or unexported fields

    Config struct constructs a new configuration handler.

    func NewConfig

    func NewConfig(filename string) *Config

      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

      func (c *Config) Add(section string, key string, value string)

        Add function adds a new key to the configuration. Function Add() is exactly the same as function Set().

        func (*Config) Del

        func (c *Config) Del(section string, key string)

          Del function deletes a key from the configuration.

          func (*Config) Filename

          func (c *Config) Filename() string

            Filename function returns the filename of the configuration.

            func (*Config) Get

            func (c *Config) Get(section string, key string) string

              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

              func (c *Config) Read() error

                Read function reads configurations from the file defined in Config.filename.

                func (*Config) Reset

                func (c *Config) Reset()

                  Reset function reset the map in the configuration.

                  func (*Config) Set

                  func (c *Config) Set(section string, key string, value string)

                    Set function updates the value of a key in the configuration. Function Set() is exactly the same as function Add().

                    func (*Config) SetFilename

                    func (c *Config) SetFilename(filename string)

                      SetFilename function sets the filename of the configuration.

                      func (*Config) Write

                      func (c *Config) Write() error

                        Write function writes the updated configuration back.

                        func (*Config) WriteTo

                        func (c *Config) WriteTo(filename string) error

                          WriteTo function writes the configuration to a new file. This function re-organizes the configuration and deletes all the comments.

                          Source Files