File: README.rst

package info (click to toggle)
golang-github-dlintw-goconf 0.0~git20120228.dcc0709-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, forky, sid, trixie
  • size: 100 kB
  • sloc: makefile: 10
file content (75 lines) | stat: -rw-r--r-- 1,392 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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://dlintw@github.com/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: