config

package module
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: MIT Imports: 14 Imported by: 0

README

itea-config

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
}

type Callback added in v1.1.0

type Callback interface {
	// contains filtered or unexported methods
}

type Config

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

func Init

func Init(option Option) (c *Config, err error)

func (*Config) Array

func (c *Config) Array(key string, b ...Callback) []interface{}

func (*Config) Bool

func (c *Config) Bool(key string, b ...Callback) bool

func (*Config) Get

func (c *Config) Get(key string, b ...Callback) interface{}

func (*Config) Int

func (c *Config) Int(key string, b ...Callback) int

func (*Config) Load

func (c *Config) Load(file string) (e error)

func (*Config) Map

func (c *Config) Map(key string, b ...Callback) map[string]interface{}

func (*Config) String

func (c *Config) String(key string, b ...Callback) string

func (*Config) Struct added in v1.2.1

func (c *Config) Struct(key string, s interface{}, b ...Callback) interface{}

func (*Config) StructArray added in v1.2.1

func (c *Config) StructArray(key string, s interface{}, b ...Callback) []interface{}

type ExtractorConstruct

type ExtractorConstruct func() IExtractor

ExtractorConstruct is the type for a function capable of constructing new IExtractor.

type IExtractor

type IExtractor interface {
	Load(interface{}, string)
	Get(string, ...Callback) interface{}
	String(string, ...Callback) string
	Int(string, ...Callback) int
	Bool(string, ...Callback) bool
	Array(string, ...Callback) []interface{}
	Map(string, ...Callback) map[string]interface{}
	Struct(string, interface{}, ...Callback) interface{}
	StructArray(string, interface{}, ...Callback) []interface{}
}

type ILoader added in v1.1.0

type ILoader interface {
	// contains filtered or unexported methods
}

type IProcessor

type IProcessor interface {
	Load(string) (map[string]interface{}, error)
}

func IniProcessor

func IniProcessor() IProcessor

IniProcessor returns a Processor which load ini config

func JsonProcessor

func JsonProcessor() IProcessor

JsonProcessor returns a Processor which load json config

func YamlProcessor

func YamlProcessor() IProcessor

YamlProcessor returns a Processor which load yaml config

type Ini

type Ini struct {
}

func (Ini) Load

func (y Ini) Load(file string) (map[string]interface{}, error)

load a ini config file to map data

type Json

type Json struct {
	Base
}

func (Json) Load

func (y Json) Load(file string) (map[string]interface{}, error)

load a json config file to map data

type Loader added in v1.1.0

type Loader func() string

type Option

type Option struct {
	File      string
	Processor ProcessorConstruct
	Extractor ExtractorConstruct
}

Option is used to pass multiple configuration options to Config's constructors.

type ProcessorConstruct

type ProcessorConstruct func() IProcessor

ProcessorConstruct is the type for a function capable of constructing new IProcessor.

type Reload added in v1.1.0

type Reload func(v interface{})

type Value added in v1.1.0

type Value struct {
	Key      string
	Type     string
	Value    interface{}
	Child    map[string]*Value
	Callback []Callback
}

func DefaultExtractor

func DefaultExtractor() *Value

func (*Value) Array added in v1.1.0

func (v *Value) Array(key string, b ...Callback) []interface{}

func (*Value) Bool added in v1.1.0

func (v *Value) Bool(key string, b ...Callback) bool

func (*Value) Get added in v1.1.0

func (v *Value) Get(key string, b ...Callback) interface{}

func (*Value) Int added in v1.1.0

func (v *Value) Int(key string, b ...Callback) int

func (*Value) Load added in v1.1.0

func (v *Value) Load(m interface{}, name string)

func (*Value) Map added in v1.1.0

func (v *Value) Map(key string, b ...Callback) map[string]interface{}

func (*Value) String added in v1.1.0

func (v *Value) String(key string, b ...Callback) string

func (*Value) Struct added in v1.2.1

func (v *Value) Struct(key string, s interface{}, b ...Callback) interface{}

func (*Value) StructArray added in v1.2.1

func (v *Value) StructArray(key string, s interface{}, b ...Callback) []interface{}

type Yaml

type Yaml struct {
	Base
}

func (Yaml) Load

func (y Yaml) Load(file string) (map[string]interface{}, error)

load a yaml config file to map data

Jump to

Keyboard shortcuts

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