Categorygithub.com/dlintw/goconf
modulepackage
0.0.0-20120228082610-dcc070983490
Repository: https://github.com/dlintw/goconf.git
Documentation: pkg.go.dev

# README

Introduction

This package is adopt from http://code.google.com/p/goconf/ And porting it to Go 1 spec.

INSTALL

assume your local package path is $HOME/go::

export GOPATH=$HOME/go

method 1:

go get github.com/dlintw/goconf go test github.com/dlintw/goconf # test it

method 2:

cd $GOPATH/src hg clone https://[email protected]/dlintw/goconf.git cd goconf make make test # test it

USAGE

sample usage::

import "github.com/dlintw/goconf"

NOTE: All section names and options are case insensitive. All values are case sensitive.

Example 1

Config::

host = something.com port = 443 active = true compression = off

Code::

c, err := goconf.ReadConfigFile("something.config") c.GetString("default", "host") // return something.com c.GetInt("default", "port") // return 443 c.GetBool("default", "active") // return true c.GetBool("default", "compression") // return false

Example 2

Config::

[default] host = something.com port = 443 active = true compression = off

[service-1] compression = on

[service-2] port = 444

Code::

c, err := goconf.ReadConfigFile("something.config") c.GetBool("default", "compression") // returns false c.GetBool("service-1", "compression") // returns true c.GetBool("service-2", "compression") // returns GetError

.. vi:set et sw=2 ts=2:

# Functions

NewConfigFile creates an empty configuration representation.
No description provided by the author
ReadConfigFile reads a file and returns a new configuration representation.

# Constants

Read Errors.
Get and Read Errors.
No description provided by the author
No description provided by the author
Get Errors.

# Variables

Strings accepted as bool.
Default section name (must be lower-case).
Maximum allowed depth when recursively substituing variable names.

# Structs

ConfigFile is the representation of configuration settings.
No description provided by the author
No description provided by the author