config

package
v0.1.2-0...-b366f10 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2013 License: Apache-2.0, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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

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 added in v0.1.1

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 added in v0.1.1

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

Del function deletes a key from the configuration.

func (*Config) Filename added in v0.1.1

func (c *Config) Filename() string

Filename function returns the filename of the configuration.

func (*Config) Get added in v0.1.1

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 added in v0.1.1

func (c *Config) Read() error

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

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 added in v0.1.1

func (c *Config) SetFilename(filename string)

SetFilename function sets the filename of the configuration.

func (*Config) Write added in v0.1.1

func (c *Config) Write() error

Write function writes the updated configuration back.

func (*Config) WriteTo added in v0.1.1

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.

Jump to

Keyboard shortcuts

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