config

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvConfFile env conf file
	EnvConfFile = "CONF_FILE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Configure

type Configure struct{ Parser }

Configure ...

func NewConfigure

func NewConfigure() *Configure

NewConfigure create new configure default parser is JSONParser

func (*Configure) LoadFromTo added in v0.1.6

func (c *Configure) LoadFromTo(r io.Reader, v any) error

LoadFromTo load from r and parse to v

func (*Configure) LoadTo

func (c *Configure) LoadTo(v any, paths ...string) error

Load load config and parse to c check env, input param

func (*Configure) WithParser added in v0.1.6

func (c *Configure) WithParser(p Parser)

WithParser set parser

type Parser

type Parser = func(any, []byte) error

Parser get parser

var (
	// jsonParser parse json config
	JSONParser Parser = func(v any, data []byte) error {
		return json.Unmarshal(data, v)
	}
	// yamlParser parse yaml config
	YAMLParser Parser = func(v any, data []byte) error {
		return yaml.Unmarshal(data, v)
	}
)

Jump to

Keyboard shortcuts

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