Documentation ¶
Index ¶
- func Downcase(values []string) (result []string)
- func FilterByWildcard(patterns interface{}, list interface{}, ignore_case bool) (result []string)
- func FormatParameter(section string, id string, parameter string) string
- func FormatSection(section string, id string) string
- func Match(pattern string, text string) *[]string
- func MatchWildcard(patterns interface{}, list interface{}, ignore_case bool) bool
- func NormalizeLine(ctx *ParseContext, text string) (string, bool)
- func ReplaceVariables(ctx *ParseContext, text string, definitions map[string]string) (newtext string, unreplaced []string)
- func SplitColon(ctx *ParseContext, text string) (string, string)
- func SplitDefine(ctx *ParseContext, text string) (name string, value string, isDefine bool)
- func SplitEqual(ctx *ParseContext, text string) (string, string)
- func SplitSection(ctx *ParseContext, text string) (name string, id string, isSection bool)
- func SplitSpace(ctx *ParseContext, text string) (string, string)
- func SplitSpaceOrEqual(ctx *ParseContext, text string) (string, string)
- func SplitTag(tag string) (section string, sid string, param string)
- func SplitUndefine(ctx *ParseContext, text string) (name string, isUndefine bool)
- func Tokenize(text string) (tokens []string)
- func Unique(list []string) (result []string)
- func Upcase(values []string) (result []string)
- type Config
- func (c *Config) AbsolutePath(f string) string
- func (c *Config) All(tag string) *Values
- func (c *Config) CanInherit(tag string) bool
- func (c *Config) Dump(with_source bool)
- func (c *Config) ErrMissing(section string) error
- func (c *Config) Error(v interface{}, args ...interface{}) error
- func (c *Config) First(tag string) (v *Value)
- func (c *Config) FirstOrDefault(tag string, defval *Value) (v *Value)
- func (c *Config) Get(tag string) *Values
- func (c *Config) IsSet(tag string) bool
- func (c *Config) Last(tag string) (v *Value)
- func (c *Config) LastOrDefault(tag string, defval *Value) (v *Value)
- func (c *Config) Load(file string) (err error)
- func (c *Config) One(tag string) *Value
- func (c *Config) OneOrDefault(tag string, defval *Value) *Value
- func (c *Config) Parameter(section string, id string, parameter string) *Parameter
- func (c *Config) Parse(text string, file string)
- func (c *Config) Section(section string, id string) *Section
- func (c *Config) SectionIds(section string) (result []string)
- func (c *Config) SectionNames() (result []string)
- func (c *Config) Sections() *[]Section
- func (c *Config) SetSchema(config *Config) error
- func (c *Config) String(tag string) string
- func (c *Config) Strings(tag string) (result []string)
- func (c *Config) Tokens(tag string, downcase bool) (tokens []string)
- func (c *Config) UniqueTokens(tag string, downcase bool) (tokens []string)
- func (c *Config) Validate() error
- type DefineSplitterFunc
- type KeyValSplitterFunc
- type NormalizerFunc
- type Parameter
- func (p *Parameter) Dump(with_source bool)
- func (p Parameter) FindValues() *Values
- func (p Parameter) First() (v *Value)
- func (p Parameter) FirstOrDefault(defval *Value) (v *Value)
- func (p Parameter) Float32() (float32, bool)
- func (p Parameter) Float32OrDefault(defval float32) float32
- func (p Parameter) Float64() (float64, bool)
- func (p Parameter) Float64OrDefault(defval float64) float64
- func (p Parameter) Floats32() []float32
- func (p Parameter) Floats64() []float64
- func (p Parameter) IP() net.IP
- func (p Parameter) IP4() net.IP
- func (p Parameter) IP4s() (result []net.IP)
- func (p Parameter) IP6() net.IP
- func (p Parameter) IP6s() (result []net.IP)
- func (p Parameter) IPs() (result []net.IP)
- func (p Parameter) Int() (int, bool)
- func (p Parameter) Int32() (int32, bool)
- func (p Parameter) Int32OrDefault(defval int32) int32
- func (p Parameter) Int64() (int64, bool)
- func (p Parameter) Int64OrDefault(defval int64) int64
- func (p Parameter) IntOrDefault(defval int) int
- func (p Parameter) Interpreted() []string
- func (p Parameter) Ints() []int
- func (p Parameter) Ints32() []int32
- func (p Parameter) Ints64() []int64
- func (p Parameter) IsOff() bool
- func (p Parameter) IsOn() bool
- func (p Parameter) Last() (v *Value)
- func (p Parameter) LastOrDefault(defval *Value) (v *Value)
- func (p Parameter) NonEmptyStringOrDefault(defval string) string
- func (p Parameter) Raw() []string
- func (p Parameter) String() string
- func (p Parameter) StringOrDefault(defval string) string
- func (p Parameter) Strings() []string
- func (p *Parameter) Tag() string
- func (p Parameter) Tokens(downcase bool) (tokens []string)
- func (p Parameter) Unique(ignorecase bool) (result Values)
- func (p Parameter) UniqueTokens(downcase bool) (tokens []string)
- func (p Parameter) Values() *Values
- type ParseContext
- type ReplacerFunc
- type Section
- func (s *Section) Dump(with_source bool)
- func (s *Section) ErrID(p string) error
- func (s *Section) ErrMissing(p string) error
- func (s *Section) Error(v interface{}, args ...interface{}) error
- func (s *Section) FindParameter(parameter string) *Parameter
- func (s Section) First(parameter string) (v *Value)
- func (s Section) FirstOrDefault(parameter string, defval *Value) (v *Value)
- func (s Section) Float32(parameter string) (float32, bool)
- func (s Section) Float32OrDefault(parameter string, defval float32) float32
- func (s Section) Float64(parameter string) (float64, bool)
- func (s Section) Float64OrDefault(parameter string, defval float64) float64
- func (s Section) Floats32(parameter string) (result []float32)
- func (s Section) Floats64(parameter string) (result []float64)
- func (s Section) IP(parameter string) net.IP
- func (s Section) IP4(parameter string) net.IP
- func (s Section) IP4s(parameter string) (result []net.IP)
- func (s Section) IP6(parameter string) net.IP
- func (s Section) IP6s(parameter string) (result []net.IP)
- func (s Section) IPs(parameter string) (result []net.IP)
- func (s Section) Int(parameter string) (int, bool)
- func (s Section) Int32(parameter string) (int32, bool)
- func (s Section) Int32OrDefault(parameter string, defval int32) int32
- func (s Section) Int64(parameter string) (int64, bool)
- func (s Section) Int64OrDefault(parameter string, defval int64) int64
- func (s Section) IntOrDefault(parameter string, defval int) int
- func (s Section) Interpreted(parameter string) []string
- func (s Section) Ints(parameter string) (result []int)
- func (s Section) Ints32(parameter string) (result []int32)
- func (s Section) Ints64(parameter string) (result []int64)
- func (s *Section) IsInherited(parameter string) bool
- func (s Section) IsOff(parameter string) bool
- func (s Section) IsOn(parameter string) bool
- func (s *Section) IsSet(parameter string) bool
- func (s Section) Last(parameter string) (v *Value)
- func (s Section) LastOrDefault(parameter string, defval *Value) (v *Value)
- func (s *Section) Need(parameters ...string) error
- func (s Section) NeedString(parameter string) (string, error)
- func (s Section) NeedValue(parameter string) (*Value, error)
- func (s Section) NeedValues(parameter string) (*Values, error)
- func (s Section) NonEmptyStringOrDefault(parameter string, defval string) string
- func (s *Section) Parameter(parameter string) *Parameter
- func (s *Section) ParameterNames() (result []string)
- func (s *Section) Parameters() *[]Parameter
- func (s Section) Raw(parameter string) []string
- func (s Section) String(parameter string) string
- func (s Section) StringOrDefault(parameter string, defval string) string
- func (s Section) Strings(parameter string) (result []string)
- func (s *Section) Tag() string
- func (s Section) Tokens(parameter string, downcase bool) (tokens []string)
- func (s Section) Unique(parameter string, ignorecase bool) (result Values)
- func (s Section) UniqueTokens(parameter string, downcase bool) (tokens []string)
- func (s Section) Value(parameter string) (v *Value)
- func (s Section) Values(parameter string) (result *Values)
- type SectionSplitterFunc
- type Source
- type Tags
- type UndefineSplitterFunc
- type Value
- func (v Value) AbsolutePath(p string) (result string, err error)
- func (v *Value) Any() bool
- func (v *Value) Empty() bool
- func (v Value) ErrEmpty() error
- func (v Value) ErrInvalid() error
- func (v Value) Error(i interface{}, args ...interface{}) error
- func (v Value) Float() (float64, bool)
- func (v Value) Float32() (float32, bool)
- func (v Value) Float64() (float64, bool)
- func (v Value) IP() net.IP
- func (v Value) IP4() net.IP
- func (v Value) IP6() net.IP
- func (v Value) Int() (int, bool)
- func (v Value) Int32() (int32, bool)
- func (v Value) Int64() (int64, bool)
- func (v Value) Interpreted() string
- func (v Value) IsOff() bool
- func (v Value) IsOn() bool
- func (v Value) Path() string
- func (v Value) PathFor(relpath string) string
- func (v Value) Raw() string
- func (v Value) RelativePath(p string) string
- func (v Value) String() string
- func (v Value) StringOrDefault(def string) string
- func (v *Value) StringWithTags() (string, Tags, error)
- func (v *Value) Tags() (Tags, error)
- func (v Value) Tokens(downcase bool) (tokens []string)
- func (v Value) UniqueTokens(downcase bool) (tokens []string)
- type Values
- func (vals Values) First() (v *Value)
- func (vals Values) FirstOrDefault(defval *Value) (v *Value)
- func (vals Values) Float32() (float32, bool)
- func (vals Values) Float32OrDefault(defval float32) (result float32)
- func (vals Values) Float64() (float64, bool)
- func (vals Values) Float64OrDefault(defval float64) (result float64)
- func (vals Values) Floats32() (result []float32)
- func (vals Values) Floats64() (result []float64)
- func (vals Values) IP() net.IP
- func (vals Values) IP4() net.IP
- func (vals Values) IP4OrDefault(defval net.IP) (result net.IP)
- func (vals Values) IP4s() (result []net.IP)
- func (vals Values) IP6() net.IP
- func (vals Values) IP6OrDefault(defval net.IP) (result net.IP)
- func (vals Values) IP6s() (result []net.IP)
- func (vals Values) IPOrDefault(defval net.IP) (result net.IP)
- func (vals Values) IPs() (result []net.IP)
- func (vals Values) Int() (int, bool)
- func (vals Values) Int32() (int32, bool)
- func (vals Values) Int32OrDefault(defval int32) (result int32)
- func (vals Values) Int64() (int64, bool)
- func (vals Values) Int64OrDefault(defval int64) (result int64)
- func (vals Values) IntOrDefault(defval int) (result int)
- func (vals Values) Interpreted() (result []string)
- func (vals Values) Ints() (result []int)
- func (vals Values) Ints32() (result []int32)
- func (vals Values) Ints64() (result []int64)
- func (vals Values) IsOff() bool
- func (vals Values) IsOn() bool
- func (vals Values) Last() (v *Value)
- func (vals Values) LastOrDefault(defval *Value) (v *Value)
- func (vals Values) NonEmptyStringOrDefault(defval string) (result string)
- func (vals Values) Raw() (result []string)
- func (vals Values) String() string
- func (vals Values) StringOrDefault(defval string) string
- func (vals Values) Strings() (result []string)
- func (vals Values) Tokens(downcase bool) (tokens []string)
- func (vals Values) Unique(ignorecase bool) (result Values)
- func (vals Values) UniqueTokens(downcase bool) (tokens []string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterByWildcard ¶
func FormatSection ¶
func MatchWildcard ¶
func NormalizeLine ¶
func NormalizeLine(ctx *ParseContext, text string) (string, bool)
Normalize line by replacing tabs by spaces, trimming whitespace on both ends and removing comments
func ReplaceVariables ¶
func SplitColon ¶
func SplitColon(ctx *ParseContext, text string) (string, string)
func SplitDefine ¶
func SplitDefine(ctx *ParseContext, text string) (name string, value string, isDefine bool)
func SplitEqual ¶
func SplitEqual(ctx *ParseContext, text string) (string, string)
func SplitSection ¶
func SplitSection(ctx *ParseContext, text string) (name string, id string, isSection bool)
func SplitSpace ¶
func SplitSpace(ctx *ParseContext, text string) (string, string)
func SplitSpaceOrEqual ¶
func SplitSpaceOrEqual(ctx *ParseContext, text string) (string, string)
func SplitUndefine ¶
func SplitUndefine(ctx *ParseContext, text string) (name string, isUndefine bool)
Types ¶
type Config ¶
type Config struct { File string Hash string SectionList []Section Warnings []string Schema *Config ValidationErrors []string Normalizer NormalizerFunc // function normalizing a line (trimming, removing comments, ...) Replacer ReplacerFunc // function replacing defined variables DefineSplitter DefineSplitterFunc // function splitting variable definition into key and value UndefineSplitter UndefineSplitterFunc // " same for undefining a variable SectionSplitter SectionSplitterFunc // function splitting a line into section and id KeyValSplitter KeyValSplitterFunc // function splitting a line into key and value Inherit interface{} // bool, string, []string, *regexp.Regexp, *[]regexp.Regexp BadNames *regexp.Regexp // do not include resolved files matching this regexp GoodNames *regexp.Regexp // only include resolved files matching this regexp PreferFirstValue bool // if true, use the first value for single value expressions; overridden by schema RawSections map[string]interface{} // sections that should be treated as containing raw data Custom map[string]interface{} // custom settings }
func Load ¶
Load creates a new Config structure, loads the given config file into it and returns a reference to the configuration data. An error is returned if the file could not be loaded. Parsing problems are logged in the structure's Warnings field.
func New ¶
func New() *Config
New returns a reference to a newly created Config structure set up with default values.
func Parse ¶
Parse creates a new Config structure, parses the given text into it and returns a reference to the configuration data. Parsing problems are logged in the structure's Warnings field.
func (*Config) AbsolutePath ¶
func (*Config) CanInherit ¶
func (*Config) ErrMissing ¶
func (*Config) FirstOrDefault ¶
func (*Config) Load ¶
Load and parse the given file into the configuration. An error is returned if the file could not be loaded. Parsing problems are logged in the structure's Warnings field.
func (*Config) Parse ¶
Parse the given file into the configuration. Parsing problems are logged in the structure's Warnings field.
func (*Config) SectionIds ¶
func (*Config) SectionNames ¶
func (*Config) UniqueTokens ¶
type DefineSplitterFunc ¶
type DefineSplitterFunc func(*ParseContext, string) (string, string, bool)
type KeyValSplitterFunc ¶
type KeyValSplitterFunc func(*ParseContext, string) (string, string)
type NormalizerFunc ¶
type NormalizerFunc func(*ParseContext, string) (string, bool)
type Parameter ¶
func (Parameter) FindValues ¶
func (Parameter) FirstOrDefault ¶
func (Parameter) Float32OrDefault ¶
func (Parameter) Float64OrDefault ¶
func (Parameter) Int32OrDefault ¶
func (Parameter) Int64OrDefault ¶
func (Parameter) IntOrDefault ¶
func (Parameter) Interpreted ¶
func (Parameter) LastOrDefault ¶
func (Parameter) NonEmptyStringOrDefault ¶
func (Parameter) StringOrDefault ¶
func (Parameter) UniqueTokens ¶
type ParseContext ¶
type ReplacerFunc ¶
type Section ¶
type Section struct { Name string ID string Source Source ParameterList []Parameter Lines []string ParameterSeq []*Parameter Config *Config // Reference to parent Config }
Section structure contains info about a section and its parameters
func (*Section) ErrMissing ¶
func (*Section) FindParameter ¶
Parameter returns a pointer to the parameter structure with the given name
func (Section) FirstOrDefault ¶
func (Section) Float32OrDefault ¶
func (Section) Float64OrDefault ¶
func (Section) Int32OrDefault ¶
func (Section) Int64OrDefault ¶
func (Section) Interpreted ¶
func (*Section) IsInherited ¶
IsInherited returns true if the parameter with the given name was set and inherited from a parent or default section.
func (Section) LastOrDefault ¶
func (*Section) Need ¶
Need checks whether the given parameters are set and non-empty and returns an error otherwise.
func (Section) NonEmptyStringOrDefault ¶
func (*Section) Parameter ¶
RawParameter returns a pointer to the named parameter's structure, or nil if there's no parameter with this name.
func (*Section) ParameterNames ¶
ParameterNames returns the names of all parameters in this section.
func (*Section) Parameters ¶
Parameters returns all parameters in this section.
func (Section) StringOrDefault ¶
func (Section) UniqueTokens ¶
type SectionSplitterFunc ¶
type SectionSplitterFunc func(*ParseContext, string) (string, string, bool)
type Tags ¶
func (Tags) HasOneValue ¶
type UndefineSplitterFunc ¶
type UndefineSplitterFunc func(*ParseContext, string) (string, bool)
type Value ¶
type Value struct { Data string Source textfile.LineSource Parameter *Parameter }
func (Value) ErrInvalid ¶
func (Value) Interpreted ¶
func (Value) RelativePath ¶
func (Value) StringOrDefault ¶
func (Value) UniqueTokens ¶
type Values ¶
type Values []Value