parser

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2018 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ini parser

This is a parser for parse INI format content to golang data

parser is ref the project: https://github.com/dombenson/go-ini, Thank you very much

Ref

License

MIT

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

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 Decode

func Decode(blob []byte, v interface{}) (err error)

Decode

func Encode

func Encode(v interface{}) (out []byte, err error)

Encode

func EncodeFullData

func EncodeFullData(data map[string]interface{}) (out []byte, err error)

EncodeFullData

func EncodeSimpleData

func EncodeSimpleData(data map[string]map[string]string) (out []byte, err error)

EncodeSimpleData

func FullParser

func FullParser(opts ...func(*parser)) *parser

FullParser

func IgnoreCase

func IgnoreCase(p *parser)

IgnoreCase

func NoDefSection

func NoDefSection(p *parser)

ParseEnv usage: parser.NewWithOptions(ini.ParseEnv)

func Parse

func Parse(data string, mode parseMode, opts ...func(*parser)) (p *parser, err error)

Parse

func SimpleParser

func SimpleParser(opts ...func(*parser)) *parser

SimpleParser

Types

type UserCollector

type UserCollector func(section, key, val string, isArr bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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