config

package module
v0.0.0-...-fc57ce9 Latest Latest
Warning

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

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

README

go-config

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultConfig = New()
)

Functions

func Bool

func Bool(key string, def ...bool) bool

func Bytes

func Bytes(key string, def ...[]byte) ([]byte, error)

func Duration

func Duration(key string, def ...time.Duration) time.Duration

func Float64

func Float64(key string, def ...float64) float64

func Get

func Get(key string) interface{}

func Int

func Int(key string, def ...int) int

func IntSlice

func IntSlice(key string, def ...[]int) []int

func Interface

func Interface(key string, def ...interface{}) interface{}

func Load

func Load() error

func Scan

func Scan(key string, v interface{}) error

func Set

func Set(key string, value interface{})

func String

func String(key string, def ...string) string

func StringMap

func StringMap(key string, def ...map[string]interface{}) map[string]interface{}

func StringMapStringSlice

func StringMapStringSlice(key string, def ...map[string][]string) map[string][]string

func StringSlice

func StringSlice(key string, def ...[]string) []string

Types

type Config

type Config interface {
	Load() error
	Get(string) interface{}
	Set(string, interface{})
	Sub(string) Config
	Data() map[string]interface{}
	SetData(map[string]interface{})

	Scan(string, interface{}) error
	Bytes(string, ...[]byte) ([]byte, error)
	Int(string, ...int) int
	IntSlice(string, ...[]int) []int
	Float64(string, ...float64) float64
	Bool(string, ...bool) bool
	String(string, ...string) string
	StringSlice(string, ...[]string) []string
	StringMap(string, ...map[string]interface{}) map[string]interface{}
	StringMapStringSlice(string, ...map[string][]string) map[string][]string
	Duration(string, ...time.Duration) time.Duration
	Interface(string, ...interface{}) interface{}
}

func LoadFile

func LoadFile(path string) (Config, error)

func New

func New(opts ...Option) Config

func Sub

func Sub(key string) Config

type Option

type Option func(*Options)

func WithCache

func WithCache() Option

func WithEncoder

func WithEncoder(e encoder.Encoder) Option

func WithEnv

func WithEnv(prefix string) Option

func WithSeparator

func WithSeparator(sep byte) Option

func WithSources

func WithSources(s ...source.Source) Option

type Options

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

Directories

Path Synopsis
env

Jump to

Keyboard shortcuts

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