parser

package
v0.0.0-...-f10f432 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvRead

func EnvRead(r io.Reader) (interface{}, error)

func EnvSimpleRead

func EnvSimpleRead(r io.Reader) (interface{}, error)

func EnvSimpleWrite

func EnvSimpleWrite(data interface{}, w io.Writer) error

func EnvWrite

func EnvWrite(data interface{}, w io.Writer) error

func JSONRead

func JSONRead(r io.Reader) (interface{}, error)

func JSONWrite

func JSONWrite(data interface{}, w io.Writer) error

func YAMLRead

func YAMLRead(r io.Reader) (interface{}, error)

func YAMLWrite

func YAMLWrite(data interface{}, w io.Writer) error

Types

type Config

type Config map[Format]Def
var Default Config

func (Config) Read

func (c Config) Read(format Format, r io.Reader) (interface{}, error)

func (Config) Write

func (c Config) Write(format Format, data interface{}, w io.Writer) error

type Def

type Def struct {
	Reader
	Writer
}

func (Def) Read

func (d Def) Read(r io.Reader) (interface{}, error)

func (Def) Write

func (d Def) Write(data interface{}, w io.Writer) error

type Format

type Format uint

Format is an identifier for config format

const (
	Auto Format = iota
	JSON
	YAML
	Env
	EnvSimple
)

constants for formats

type Reader

type Reader func(r io.Reader) (interface{}, error)

Reader loads a given file format into memory, into the same possible types as json.Unmarshal(data, anInterface). Supported types:

bool, for JSON booleans float64, for JSON numbers string, for JSON strings []interface{}, for JSON arrays map[string]interface{}, for JSON objects nil for JSON null

type Writer

type Writer func(data interface{}, w io.Writer) error

Writer writes out data (which is like the interface in `json.Unmarshal(data, anInterface)`), into a given format, via a Writer. Supported types:

bool, for JSON booleans float64, for JSON numbers string, for JSON strings []interface{}, for JSON arrays map[string]interface{}, for JSON objects nil for JSON null

Jump to

Keyboard shortcuts

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