config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Config Package.

package main

import "github.com/ije/gox/config"

func main() {
    conf, err := config.New("a.conf")
    if err != nil {
		return
    }
    log.Printf(conf.String("key", "defaultValue"))
    log.Printf(conf.Section("sectionName").String("key", "defaultValue"))
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

func New

func New(configFile string) (config *Config, err error)

func (*Config) Bool

func (config *Config) Bool(key string, def ...bool) bool

func (*Config) Bytes

func (config *Config) Bytes(key string, def ...int64) int64

func (*Config) Contains

func (config *Config) Contains(key string) bool

func (*Config) Each

func (config *Config) Each(hanlder func(key string, value string))

func (*Config) ExtendedSections

func (config *Config) ExtendedSections() map[string]Section

func (*Config) Float64

func (config *Config) Float64(key string, def ...float64) float64

func (*Config) Int

func (config *Config) Int(key string, def ...int) int

func (*Config) Int64

func (config *Config) Int64(key string, def ...int64) int64

func (*Config) IsEmpty

func (config *Config) IsEmpty() bool

func (*Config) Keys

func (config *Config) Keys() []string

func (*Config) Section

func (config *Config) Section(name string) (section Section)

func (*Config) Set

func (config *Config) Set(key string, value interface{})

func (*Config) String

func (config *Config) String(key string, extra ...string) string

type Section

type Section map[string]string

func Parse

func Parse(r io.Reader) (defaultSection Section, extendedSections map[string]Section, err error)

func (Section) Bool

func (section Section) Bool(key string, extra ...bool) bool

func (Section) Bytes

func (section Section) Bytes(key string, extra ...int64) int64

func (Section) Contains

func (section Section) Contains(key string) (ok bool)

func (Section) Each

func (section Section) Each(hanlder func(key string, value string))

func (Section) Float64

func (section Section) Float64(key string, extra ...float64) float64

func (Section) Int

func (section Section) Int(key string, extra ...int) int

func (Section) Int64

func (section Section) Int64(key string, extra ...int64) int64

func (Section) IsEmpty

func (section Section) IsEmpty() bool

func (Section) Keys

func (section Section) Keys() (keys []string)

func (Section) Set

func (section Section) Set(key string, value interface{})

func (Section) String

func (section Section) String(key string, extra ...string) string

Jump to

Keyboard shortcuts

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