kvconf

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

configure file of key=value parse library.

supported decode data to struct by reflact library, you can add "kv" tag in struct to ensure the correct keys.

you can define a custom Marshaler and Unmarshaler interface to process data by yourself.

supported decode and encode key in structure split in "." char.

supported value types:

interface{}
map[string]interface{}
struct by tag kv
map[string]<all of basic types>

basic types:

int, int8, int16, int32, int64
uint, uint8, uint16, uint32, uint64
float32, float64
bool
string

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

Decoder unmarshal decoder

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder create decoder

func (*Decoder) Decode

func (d *Decoder) Decode(v interface{}) error

Decode decode value from io.Reader, supported map[string]string and struct with kv tag

type Encoder

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

Encoder marshal encoder

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder create marshaler

func (*Encoder) Encode

func (e *Encoder) Encode(v interface{}) error

Encode encode value to io.Writer, supported map[string]string and struct with kv tag

type Marshaler

type Marshaler interface {
	MarshalKV() (string, error)
}

Marshaler custom marshaler interface, the returned string value is the encoded value to write

type Unmarshaler

type Unmarshaler interface {
	UnmarshalKV(string) error
}

Unmarshaler custom unmarshaler interface, the param of UnmarshalKV function is the value from input

type UnsupportedTypeError

type UnsupportedTypeError struct {
	Type reflect.Type
}

UnsupportedTypeError error for unsupported type

func (*UnsupportedTypeError) Error

func (e *UnsupportedTypeError) Error() string

Error error message

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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