Documentation
¶
Overview ¶
This a parser for parse INI format content to golang data
There are example data:
# comments
name = inhere
age = 28
debug = true
hasQuota1 = 'this is val'
hasQuota2 = "this is val1"
shell = ${SHELL}
noEnv = ${NotExist|defValue}
; array in def section
tags[] = a
tags[] = b
tags[] = c
; comments
[sec1]
key = val0
some = value
stuff = things
; array in section
types[] = x
types[] = y
how to use, please see examples:
Example (FullParse) ¶
p, err := Parse(iniStr, FullMode)
// p, err := Parse(iniStr, FullMode, NoDefSection)
if err != nil {
panic(err)
}
fmt.Printf("full parse:\n%#v\n", p.FullData())
Example (SimpleParse) ¶
// simple mode will ignore all array values
p, err := Parse(iniStr, SimpleMode)
if err != nil {
panic(err)
}
fmt.Printf("simple parse:\n%#v\n", p.SimpleData())
Index ¶
- Constants
- func Decode(blob []byte, v interface{}) (err error)
- func Encode(v interface{}) (out []byte, err error)
- func EncodeFullData(data map[string]interface{}) (out []byte, err error)
- func EncodeSimpleData(data map[string]map[string]string) (out []byte, err error)
- func FullParser(opts ...func(*parser)) *parser
- func IgnoreCase(p *parser)
- func NoDefSection(p *parser)
- func Parse(data string, mode parseMode, opts ...func(*parser)) (p *parser, err error)
- func SimpleParser(opts ...func(*parser)) *parser
- type UserCollector
Examples ¶
Constants ¶
View Source
const ( FullMode parseMode = 1 SimpleMode parseMode = 2 )
parse mode FullMode - will parse array SimpleMode - don't parse array value
Variables ¶
This section is empty.
Functions ¶
func EncodeFullData ¶
EncodeFullData
func EncodeSimpleData ¶
EncodeSimpleData
func NoDefSection ¶
func NoDefSection(p *parser)
ParseEnv usage: parser.NewWithOptions(ini.ParseEnv)
Types ¶
type UserCollector ¶
Click to show internal directories.
Click to hide internal directories.