parser

package
Version: v0.0.0-...-0d75033 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2018 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package parser provides parsing and serializing routines for the flagfile on-disk format

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(in io.Reader, cb func(key, value string)) error

Parse takes an io.Reader and calls the given calback for each key and unparsed value. This format is used by flagfile for loading and serializing flags.

The file format understands comments (provided the line starts with a comment character ('#' or ';')), and essentially has macros for prefixes. If a line that starts with '[' and ends with ']' is found, that is used as the key prefix for the remaining keys until the next prefix macro. Prefixes are automatically joined with a '.'. The special prefix "main" stops prefix handling.

An example file:

some.flag = 20
# some.other.flag = 50
flag3 = 10m
flag4 = a string value

[section1]
flag1 = 30
flag2 = 40

[section2]
flag1 = 50
flag2 = true

func Serialize

func Serialize(values map[string]string, out io.Writer) error

Serialize is the inverse of Parse. It automatically sorts the given keys and makes sections.

Types

This section is empty.

Jump to

Keyboard shortcuts

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