ini

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 8 Imported by: 0

README

Ini

A simple standard ini parser with golang.

Install


$ go get github.com/nonzzz/ini

Features

  • Read by file.
  • Read by string.
  • Marshal to Json or Map.
  • Friendly Selector

Usage


i := ini.New()

//  Load File
i.LoadFile("your ini file")

// Parse

txt :=`

[s]

a = 3

[s1]

b = 4

`

ini.Parse(txt)

Document

Acknowledgements

Thanks to JetBrains for allocating free open-source licences for IDEs.

GoLand logo.

Author

Kanno

LICENSE

MIT

Documentation

Index

Constants

View Source
const (
	SectionKind    = ast.KSection
	ExpressionKind = ast.KExpression
	CommentKind    = ast.KComment
)

Variables

This section is empty.

Functions

func NewNode added in v0.2.0

func NewNode(kind ast.K) ast.Element

func UpdateNodeAttributeBindings added in v0.2.0

func UpdateNodeAttributeBindings(node ast.Element, bindings AttributeBindings)

Types

type AttributeBindings added in v0.2.0

type AttributeBindings struct {
	Id    string
	Text  string
	Key   string
	Value string
}

type Ini

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

func New

func New() *Ini

func (*Ini) LoadFile

func (i *Ini) LoadFile(file string) (*Ini, error)

func (*Ini) Marshal2Json

func (i *Ini) Marshal2Json() []byte

func (*Ini) Marshal2Map

func (i *Ini) Marshal2Map() map[string]interface{}

func (*Ini) Parse

func (i *Ini) Parse(input string) *Ini

func (*Ini) Printer

func (i *Ini) Printer() (string, error)

type Operate added in v0.2.0

type Operate interface {
	Get() (ast.Element, error)
	Set(bindings AttributeBindings) bool
	Delete() bool
}

type Selector added in v0.2.0

type Selector interface {
	Query(id string, kind ast.K) Operate
}

func NewSelector added in v0.2.0

func NewSelector(accept interface{}) Selector

Directories

Path Synopsis
internal
ast

Jump to

Keyboard shortcuts

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