config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultProfile      = "default"
	DefaultConfigFormat = "yaml"
	DefaultConfigPath   = "./config"
)

Variables

View Source
var ErrFormatNotSupported = errors.New("config format is not supported")

Functions

func MapStructurePlaceholderValueHook

func MapStructurePlaceholderValueHook() mapstructure.DecodeHookFunc

Types

type AppProperties

type AppProperties struct {
	Name string `default:"unspecified"`
	Port int    `default:"8080"`
	Path string `default:"/"`
}

func NewAppProperties

func NewAppProperties(loader Loader) (*AppProperties, error)

func (AppProperties) Prefix

func (a AppProperties) Prefix() string

type DebugFunc

type DebugFunc func(msgFormat string, args ...interface{})

type DefaultProfileReader

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

func NewDefaultProfileReader

func NewDefaultProfileReader(scanPaths []string, format string, delim string) (*DefaultProfileReader, error)

func (DefaultProfileReader) Read

func (p DefaultProfileReader) Read(profile string) (map[string]interface{}, error)

type Loader

type Loader interface {
	Bind(properties ...Properties) error
}

func NewLoader

func NewLoader(option Option, properties []Properties) (Loader, error)

type Option

type Option struct {
	ActiveProfiles []string
	ConfigPaths    []string
	ConfigFormat   string // yaml, json
	KeyDelimiter   string
	DebugFunc      DebugFunc
}

type ProfileReader

type ProfileReader interface {

	// Read config in a profile
	Read(profile string) (map[string]interface{}, error)
}

type Properties

type Properties interface {
	Prefix() string
}

type PropertiesPostBinding

type PropertiesPostBinding interface {
	PostBinding() error
}

type PropertiesPreBinding

type PropertiesPreBinding interface {
	PreBinding() error
}

type ViperLoader

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

func (*ViperLoader) Bind

func (l *ViperLoader) Bind(propertiesList ...Properties) error

Jump to

Keyboard shortcuts

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