config

package
v0.41.8 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any(key string) (interface{}, error)

Any 获取指定 key 对应的数据

func C

func C(key string) (string, error)

C 获取配置

func CB

func CB(key string) (bool, error)

CB 获取配置,结果转为 bool

func CF32

func CF32(key string) (float32, error)

CF32 获取配置,结果转为 float32

func CF64

func CF64(key string) (float64, error)

CF64 获取配置,结果转为 float64

func CI

func CI(key string) (int, error)

CI 获取配置,结果转为 int

func CI32

func CI32(key string) (int32, error)

CI32 获取配置,结果转为 CI32

func CI64

func CI64(key string) (int64, error)

CI64 获取配置,结果转为 int64

func D

func D(key, def string) string

D 获取配置

func DB

func DB(key string, def bool) bool

DB 获取配置,结果转为 bool

func DF32

func DF32(key string, def float32) float32

DF32 获取配置,结果转为 float32

func DF64

func DF64(key string, def float64) float64

DF64 获取配置,结果转为 float64

func DI

func DI(key string, def int) int

DI 获取配置,结果转为 int

func DI32

func DI32(key string, def int32) int32

DI32 获取配置,结果转为 int32

func DI64

func DI64(key string, def int64) int64

DI64 获取配置,结果转为 int64

Types

type Config

type Config interface {
	// LoadJSON 从 bytes 数据中读取配置
	LoadJSON(bytes []byte) error

	// LoadTOML 从 bytes 数据中读取配置
	LoadTOML(bytes []byte) error

	// LoadYAML 从 bytes 数据中读取配置
	LoadYAML(bytes []byte) error

	// FileJSON 从 json 文件中读取配置
	FileJSON(path string) error

	// FileTOML 从 toml 文件中读取配置
	FileTOML(path string) error

	// FileYAML 从 yaml 文件中读取配置
	FileYAML(path string) error

	// Any 根据 key 获取对应数据
	Any(key string) (interface{}, error)
}

Config 配置文件

func NewConfig

func NewConfig() Config

NewConfig 生成一个配置文件实例

Jump to

Keyboard shortcuts

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