go-config

module
v0.0.0-...-0bf5eaf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2012 License: BSD-3-Clause

README

go-config

The package implements a basic INI configuration file reader. Its interface is heavily influenced by encoding/csv Go package.

The configuration file consists of sections, led by a [section] header and followed by key-value options (name = value or name=value). Leading whitespace is removed from values.

For example:

[Some section]
foo: bar
fur = foo

Installation

go get github.com/Claymore/go-config/config

Examples

    package main

    import (
        "github.com/Claymore/go-config/config"
        "fmt"
        "os"
    )

    func main() {
        file, err := os.Open("example.cfg")
        if err != nil {
            fmt.Println("Error:", err)
            return
        }
        defer file.Close()
        reader := config.NewReader(file)
        sections, err := reader.ReadAll()
        if err != nil {
            fmt.Println("Error:", err)
            return
        }
        for section, options := range sections {
            fmt.Println(section, options)
        }
    }

See also

See kless/goconfig for Python ConfigParser flavoured API.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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