ini

package module
v0.0.0-...-cc8fbd8 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: CC0-1.0 Imports: 6 Imported by: 1

Documentation

Overview

Package ini is a minimal markup language for config files

Specification:

Entries:

  1. an entry contains three fields a. section of type string a. key of type string b. value of type string c. comment of type string

Parser state:

0. a section of type string, initially empty 1. a comment of type string, initially empty

Parser semantics:

  1. the byte stream is broken up into lines a. lines are split by the separator regex '\r?\n' b. a separator may be escaped with '\' causing it not to split c. an escaping '\' is removed from the contents of the line d. the line is always joined with '\n'

1. lines beginning with '#' are comments and are ignored

2. empty space trimmed lines are valid and ignored

  1. lines beginning with '[' and ending with ']' are section declarations a. the line is invalid if the contents contain '[', ']', '\', '=', or '#' b. the contents between the '[' and ']' become the section c. the comment state is reset to empty
  1. lines containing the string "=" are entries a. the entry key is the space trimmed portion before the first "=" b. the entry value is the space trimmed portion after the first "=" c. the comment state has the final '\n' removed, if it exists d. entries are immediately emitted e. when an entry is emitted, the comment state is reset to empty
  1. anything else is an invalid line a. invalid lines causes Read to return an error

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(r io.Reader, cb func(ent Entry) error) error

func Write

func Write(w io.Writer, cb func(emit func(ent Entry))) error

Types

type Entry

type Entry struct {
	Section string
	Key     string
	Value   string
}

Jump to

Keyboard shortcuts

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