config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidProvider when provider invalid return
	ErrInvalidProvider = errors.New("config: invalid config center provider")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Provider string
	Addr     string
	Path     string
	// contains filtered or unexported fields
}

Config struct

func New

func New(addr, path string) (*Config, error)

New return config instance

func (*Config) GetBool

func (c *Config) GetBool(key string, fallback bool) bool

GetBool use for get bool-type value

func (*Config) GetDuration

func (c *Config) GetDuration(key string, fallback time.Duration) time.Duration

GetDuration returns the value associated with the key as a duration

func (*Config) GetFloat64

func (c *Config) GetFloat64(key string, fallback float64) float64

GetFloat64 returns the value associated with the key as a float64

func (*Config) GetInt

func (c *Config) GetInt(key string, fallback int) int

GetInt use for get int-type value

func (*Config) GetIntSlice

func (c *Config) GetIntSlice(key string, fallback []int) []int

GetIntSlice returns the value associated with the key as a slice of int values

func (*Config) GetString

func (c *Config) GetString(key string, fallback string) string

GetString use for get string-type value

func (*Config) GetStringMap

func (c *Config) GetStringMap(key string, fallback map[string]interface{}) map[string]interface{}

GetStringMap returns the value associated with the key as a map of interfaces

func (*Config) GetStringMapString

func (c *Config) GetStringMapString(key string, fallback map[string]string) map[string]string

GetStringMapString returns the value associated with the key as a map of strings

func (*Config) GetStringMapStringSlice

func (c *Config) GetStringMapStringSlice(key string, fallback map[string][]string) map[string][]string

GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings

func (*Config) GetStringSlice

func (c *Config) GetStringSlice(key string, fallback []string) []string

GetStringSlice returns the value associated with the key as a slice of strings

func (*Config) GetTime

func (c *Config) GetTime(key string, fallback time.Time) time.Time

GetTime returns the value associated with the key as time

func (*Config) IsSet

func (c *Config) IsSet(key string) bool

IsSet use for detected key isset

func (*Config) Load

func (c *Config) Load() error

Load use for load config

type Configer

type Configer interface {
	GetString(key string, fallback string) string
	GetInt(key string, fallback int) int
	GetBool(key string, fallback bool) bool
	GetIntSlice(key string, fallback []int) []int
	GetStringSlice(key string, fallback []string) []string
	GetStringMap(key string, fallback map[string]interface{}) map[string]interface{}
	GetStringMapString(key string, fallback map[string]string) map[string]string
	GetStringMapStringSlice(key string, fallback map[string][]string) map[string][]string
	GetTime(key string, fallback time.Time) time.Time
	GetDuration(key string, fallback time.Duration) time.Duration
	GetFloat64(key string, fallback float64) float64
	IsSet(key string) bool
}

Configer interface

Jump to

Keyboard shortcuts

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