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, ModeFull)
// p, err := Parse(iniStr, ModeFull, 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, ModeSimple)
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{}, defSection ...string) (out []byte, err error)
- func EncodeFull(data map[string]interface{}, defSection ...string) (out []byte, err error)
- func EncodeSimple(data map[string]map[string]string, defSection ...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 ( ModeFull parseMode = 1 ModeSimple parseMode = 2 )
parse mode ModeFull - will parse array ModeSimple - don't parse array value
Variables ¶
This section is empty.
Functions ¶
func EncodeFull ¶ added in v1.0.4
EncodeFull
func EncodeSimple ¶ added in v1.0.4
EncodeSimple
func FullParser ¶
func FullParser(opts ...func(*parser)) *parser
FullParser create a full mode parser
func NoDefSection ¶
func NoDefSection(p *parser)
NoDefSection set don't return DefSection title usage: parser.NewWithOptions(ini.ParseEnv)
func SimpleParser ¶
func SimpleParser(opts ...func(*parser)) *parser
SimpleParser create a simple mode parser
Types ¶
type UserCollector ¶
UserCollector custom data collector. notice: in simple mode, isArr always is false.
Click to show internal directories.
Click to hide internal directories.