config

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2016 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool

The global debug flag

View Source
var ErrNotInitialized = errors.New("the configuration was not initialized")

Error is paniked if the global configuration was not initialized.

View Source
var RootDir string

The root directory of cloudway installation.

Functions

func AddOption

func AddOption(section, key, value string)

AddOption add a configuration value into the given section.

func Get

func Get(key string) string

Get a configuration value as string

func GetOption

func GetOption(section, key string) string

GetFrom get a configuration value from the given section.

func GetOrDefault

func GetOrDefault(key, deflt string) string

GetOrDefault get a configuration value, if no such value configured then the default value is returned.

func GetSection

func GetSection(section string) map[string]string

GetSection get section in the configuration file.

func GetSections

func GetSections() []string

GetSections returns the list of sections in the configuration.

func Initialize

func Initialize() (err error)

Initializes the global configuration file.

func InitializeClient

func InitializeClient() (err error)

Initialize the client configuration file.

func Remove

func Remove(key string)

Remove a key from configuration.

func RemoveOption

func RemoveOption(section, key string)

RemoveOption removes a configuration value from the given section.

func RemoveSection

func RemoveSection(section string)

RemoveSection remove a section from configuration.

func Save

func Save() (err error)

Save global configurations to file.

func Set

func Set(key, value string)

Set a configuration of the given key to the given value.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

func New

func New(filename string) *Config

Create a new configuration.

func Open

func Open(filename string) (*Config, error)

Open Configuration file from the give file name.

func (*Config) AddOption

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

AddOption add a configuration value into the given section.

func (*Config) Get

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

Get a configuration value as string.

func (*Config) GetOption

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

GetFrom get a configuration value from the given section.

func (*Config) GetOrDefault

func (c *Config) GetOrDefault(key, deflt string) string

GetOrDefault get a configuration value, if no such value configured then the default value is returned.

func (*Config) GetSection

func (c *Config) GetSection(section string) map[string]string

GetSection get a section in the configuration file.

func (*Config) GetSections

func (c *Config) GetSections() []string

GetSections returns the list of sections in the configuration.

func (*Config) Remove

func (c *Config) Remove(key string)

Remove a key from configuration.

func (*Config) RemoveOption

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

RemoveFrom removes a configuration value from the given section.

func (*Config) RemoveSection

func (c *Config) RemoveSection(section string)

RemoveSection remove a section from configuration.

func (*Config) Save

func (c *Config) Save() (err error)

Save configurations to file.

func (*Config) Set

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

Set a configuration of the given key to the given value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL