config

package
v0.0.0-...-66c0836 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const CONFIGPREFIX = "config="

Variables

View Source
var ConfPath string

Functions

func Bool

func Bool(option string) (result, found bool)

func BoolDefault

func BoolDefault(option string, dfault bool) bool

func HasConfigInit

func HasConfigInit() bool

func HasSection

func HasSection(section string) bool

func InitModule

func InitModule() error

func InitModuleByParams

func InitModuleByParams(filename string) error

func Int

func Int(option string) (result int, found bool)

func IntDefault

func IntDefault(option string, dfault int) int

func Options

func Options(prefix string) []string

func SetOption

func SetOption(name, value string)

func SetSection

func SetSection(section string)

func String

func String(option string) (result string, found bool)

func StringDefault

func StringDefault(option, dfault string) string

Types

type IConfig

type IConfig interface {
	SetSection(section string)
	SetOption(name, value string)
	Int(option string) (result int, found bool)
	IntDefault(option string, dfault int) int
	Bool(option string) (result, found bool)
	BoolDefault(option string, dfault bool) bool
	String(option string) (result string, found bool)
	StringDefault(option, dfault string) string
	HasSection(section string) bool
	Options(prefix string) []string
}

type MergedConfig

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

This handles the parsing of app.conf It has a "preferred" section that is checked first for option queries. If the preferred section does not have the option, the DEFAULT section is checked fallback.

var Config *MergedConfig

func LoadConfig

func LoadConfig(confName string) (*MergedConfig, error)

func NewEmptyConfig

func NewEmptyConfig() *MergedConfig

func (*MergedConfig) Bool

func (c *MergedConfig) Bool(option string) (result, found bool)

func (*MergedConfig) BoolDefault

func (c *MergedConfig) BoolDefault(option string, dfault bool) bool

func (*MergedConfig) HasSection

func (c *MergedConfig) HasSection(section string) bool

func (*MergedConfig) Int

func (c *MergedConfig) Int(option string) (result int, found bool)

func (*MergedConfig) IntDefault

func (c *MergedConfig) IntDefault(option string, dfault int) int

func (*MergedConfig) Options

func (c *MergedConfig) Options(prefix string) []string

Options returns all configuration option keys. If a prefix is provided, then that is applied as a filter.

func (*MergedConfig) Raw

func (c *MergedConfig) Raw() *config.Config

func (*MergedConfig) SetOption

func (c *MergedConfig) SetOption(name, value string)

func (*MergedConfig) SetSection

func (c *MergedConfig) SetSection(section string)

func (*MergedConfig) String

func (c *MergedConfig) String(option string) (result string, found bool)

func (*MergedConfig) StringDefault

func (c *MergedConfig) StringDefault(option, dfault string) string

Jump to

Keyboard shortcuts

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