ini

package module
v0.0.0-...-47e5250 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2014 License: Apache-2.0 Imports: 7 Imported by: 4

README

ini

Parse INI file like "flag" in Go

go get -u github.com/c4pt0r/ini

Example:

package main

import (
	"log"
	"github.com/c4pt0r/ini"
)

var conf = ini.NewConf("test.ini")

var (
	v1 = conf.String("section1", "field1", "v1")
	v2 = conf.Int("section1", "field2", 0)
)

func main() {
	conf.Parse()

	log.Println(*v1, *v2)
}

Documentation

Index

Constants

View Source
const (
	GLOBAL_SECTION = "_GLOBAL_SECTION_"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfSet

type ConfSet struct {
	// contains filtered or unexported fields
}

func NewConf

func NewConf(fname string) *ConfSet

func (*ConfSet) Bool

func (c *ConfSet) Bool(sectionName, name string, value bool) *bool

func (*ConfSet) BoolVar

func (c *ConfSet) BoolVar(p *bool, sectionName, name string, value bool)

func (*ConfSet) Duration

func (c *ConfSet) Duration(sectionName, name string, value time.Duration) *time.Duration

func (*ConfSet) DurationVar

func (c *ConfSet) DurationVar(p *time.Duration, sectionName, name string, value time.Duration)

func (*ConfSet) Float64

func (c *ConfSet) Float64(sectionName, name string, value float64) *float64

func (*ConfSet) Float64Var

func (c *ConfSet) Float64Var(p *float64, sectionName, name string, value float64)

func (*ConfSet) Int

func (c *ConfSet) Int(sectionName, name string, value int) *int

func (*ConfSet) Int64

func (c *ConfSet) Int64(sectionName, name string, value int64) *int64

func (*ConfSet) Int64Var

func (c *ConfSet) Int64Var(p *int64, sectionName, name string, value int64)

func (*ConfSet) IntVar

func (c *ConfSet) IntVar(p *int, sectionName, name string, value int)

func (*ConfSet) Parse

func (c *ConfSet) Parse() error

func (*ConfSet) String

func (c *ConfSet) String(sectionName, name string, value string) *string

func (*ConfSet) StringVar

func (c *ConfSet) StringVar(p *string, sectionName, name string, value string)

func (*ConfSet) Uint

func (c *ConfSet) Uint(sectionName, name string, value uint) *uint

func (*ConfSet) Uint64

func (c *ConfSet) Uint64(sectionName, name string, value uint64) *uint64

func (*ConfSet) Uint64Var

func (c *ConfSet) Uint64Var(p *uint64, sectionName, name string, value uint64)

func (*ConfSet) UintVar

func (c *ConfSet) UintVar(p *uint, sectionName, name string, value uint)

func (*ConfSet) Var

func (c *ConfSet) Var(val Value, sectionName, name string)

type Getter

type Getter interface {
	Value
	Get() interface{}
}

Getter is an interface that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.

type Item

type Item struct {
	SectionName string
	Name        string
	Val         Value
}

type Section

type Section struct {
	Name string
	Vals map[string]*Item
}

type Value

type Value interface {
	String() string
	Set(string) error
}

Value is the interface to the dynamic value stored in a flag. (The default value is represented as a string.)

If a Value has an IsBoolFlag() bool method returning true, the command-line parser makes -name equivalent to -name=true rather than using the next command-line argument.

Jump to

Keyboard shortcuts

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