conf

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package conf implements parse the taf config. Usage: After initialization, use obj.GetXXX("/taf/db<ip>") to get the corresponding data structure.

Index

Constants

View Source
const (
	// Node shows an element is a node
	Node = iota
	// Leaf shows an element is a leaf
	Leaf
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf

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

Conf struct for parse xml-like tars config file.

func New

func New() *Conf

New returns an new Conf struct.

func NewConf

func NewConf(fileName string) (*Conf, error)

NewConf returns a new Conf with the fileName

func (*Conf) GetBoolWithDef

func (c *Conf) GetBoolWithDef(path string, defVal bool) bool

GetBoolWithDef get bool value

func (*Conf) GetDomain

func (c *Conf) GetDomain(path string) []string

GetDomain returns the domain for pointed path

func (*Conf) GetInt

func (c *Conf) GetInt(path string) int

GetInt returns the value as an integer for pointed path

func (*Conf) GetInt32WithDef

func (c *Conf) GetInt32WithDef(path string, defVal int32) int32

GetInt32WithDef get int32 value

func (*Conf) GetIntWithDef

func (c *Conf) GetIntWithDef(path string, defVal int) int

GetIntWithDef returns the value as an integer for pointed path, or a default value when error happens

func (*Conf) GetMap

func (c *Conf) GetMap(path string) map[string]string

GetMap returns the key-value as a map for pointed path

func (*Conf) GetString

func (c *Conf) GetString(path string) string

GetString returns the value for pointed path

func (*Conf) GetStringWithDef

func (c *Conf) GetStringWithDef(path string, defVal string) string

GetStringWithDef returns the value for pointed path, or a default value when error happens

func (*Conf) InitFromBytes

func (c *Conf) InitFromBytes(content []byte) error

InitFromBytes returns error when init config from bytes

func (*Conf) InitFromFile

func (c *Conf) InitFromFile(fileName string) error

InitFromFile returns error when init config from a file

func (*Conf) InitFromString

func (c *Conf) InitFromString(content string) error

InitFromString returns error when init config from a string

func (*Conf) ToString

func (c *Conf) ToString() string

ToString returns the config as a string

Jump to

Keyboard shortcuts

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