pax_global_header00006660000000000000000000000064137417766530014535gustar00rootroot0000000000000052 comment=50f22f44deb56c97f8d87ad4f55c04806731dccc golang-github-mvo5-goconfigparser-0.2.2/000077500000000000000000000000001374177665300201575ustar00rootroot00000000000000golang-github-mvo5-goconfigparser-0.2.2/.travis.yml000066400000000000000000000001501374177665300222640ustar00rootroot00000000000000arch: - amd64 - ppc64le language: go install: - go get -t -v ./... script: - go test -v ./... golang-github-mvo5-goconfigparser-0.2.2/COPYING000066400000000000000000000020371374177665300212140ustar00rootroot00000000000000Copyright (c) 2014 Canonical Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: . The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. . THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. golang-github-mvo5-goconfigparser-0.2.2/README.md000066400000000000000000000023721374177665300214420ustar00rootroot00000000000000[![Build Status][travis-image]][travis-url] [![GoDoc][godoc-image]][godoc-url] Config File Parser (INI style) ============================== This parser is build as a go equivalent of the Python ConfigParser module and is aimed for maximum compatibility for both the file format and the API. This should make it easy to use existing python style configuration files from go and also ease the porting of existing python code. Example usage: ```golang package main import ( "fmt" "github.com/mvo5/goconfigparser" ) var cfgExample = `[service] base: something ` var cfgExample2 = `[service] base=something ` func main() { cfg := goconfigparser.New() cfg.ReadString(cfgExample) val, err := cfg.Get("service", "base") if err != nil { panic(err) } fmt.Printf("Got value %q\n", val) } ``` It implements most of RawConfigParser (i.e. no interpolation) at this point. Current Limitations: -------------------- * no interpolation * no defaults * no write support * not all API is provided [travis-image]: https://travis-ci.org/mvo5/goconfigparser.svg?branch=master [travis-url]: https://travis-ci.org/mvo5/goconfigparser [godoc-image]: https://godoc.org/github.com/mvo5/goconfigparser?status.svg [godoc-url]: https://godoc.org/github.com/mvo5/goconfigparser golang-github-mvo5-goconfigparser-0.2.2/configparser.go000066400000000000000000000111321374177665300231660ustar00rootroot00000000000000// A go implementation in the spirit of the python ConfigParser package goconfigparser import ( "bufio" "errors" "fmt" "io" "log" "os" "regexp" "strconv" "strings" ) // see python3 configparser.py var sectionRE = regexp.MustCompile(`^\[(?P
[^]]+)\]`) var optionRE = regexp.MustCompile(`^(?P