codec

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BackupTagName = "cfg"

BackupTagName is the tag name used if tagname not found in the struct tags.

Functions

func LoadReaderWithDecoder

func LoadReaderWithDecoder(r io.Reader, to interface{}, decoder Decoder, tag string) error

LoadReaderWithDecoder will decode input in `r` into `to` by using `decoder`.

func MapDecoder

func MapDecoder(input, output interface{}, tag string) error

MapDecoder implements the reformat package, it exposes functionality to convert an arbitrary map[string]interface{} into a native Go structure with given tag name.

Types

type Decoder

type Decoder interface {
	Decode(r io.Reader, to interface{}) error
}

Decoder is a interface that will decode reader `r` into `to`.

`to` will already be pointer to struct, so no need to further prepare it for decoding.

type JSON

type JSON struct {
	Strict bool
}

JSON is a json decoder.

func (JSON) Decode

func (c JSON) Decode(r io.Reader, to interface{}) error

Decode is a decoder function for json.

type TOML

type TOML struct{}

TOML is a toml decoder.

func (TOML) Decode

func (c TOML) Decode(r io.Reader, to interface{}) error

Decode is a decoder function for yaml.

type YAML

type YAML struct {
	Strict bool
}

YAML is a yaml decoder.

func (YAML) Decode

func (c YAML) Decode(r io.Reader, to interface{}) error

Decode is a decoder function for yaml.

Jump to

Keyboard shortcuts

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