conf

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TextFormat 文本格式
	TextFormat = LogFormat("text")
	// JSONFormat json格式
	JSONFormat = LogFormat("json")
)
View Source
const (
	// ToFile 保存到文件
	ToFile = LogTo("file")
	// ToStdout 打印到标准输出
	ToStdout = LogTo("stdout")
)

Variables

This section is empty.

Functions

func LoadConfigFromEnv

func LoadConfigFromEnv() error

LoadConfigFromEnv 从环境变量中加载配置

func LoadConfigFromToml

func LoadConfigFromToml(filePath string) error

LoadConfigFromToml 从toml中添加配置文件, 并初始化全局对象

Types

type Config

type Config struct {
	App     *app        `toml:"app"`
	Log     *log        `toml:"log"`
	Redis   *Redis      `toml:"redis"`
	Mongo   *mongodb    `toml:"mongodb"`
	Mcenter *rpc.Config `toml:"mcenter"`
}

Config 应用配置

func C

func C() *Config

C 全局配置对象

func (*Config) InitGlobal

func (c *Config) InitGlobal() error

初始化全局配置

type LogFormat

type LogFormat string

LogFormat 日志格式

type LogTo

type LogTo string

LogTo 日志记录到哪儿

type Redis added in v1.4.0

type Redis struct {
	Address  string `toml:"address" env:"REDIS_ADDRESS"`
	Password string `toml:"password" env:"REDIS_PASSWORD"`
	DB       int    `toml:"db" env:"REDIS_DB"`
	// contains filtered or unexported fields
}

func (*Redis) Client added in v1.4.0

func (r *Redis) Client() *redis.Client

Jump to

Keyboard shortcuts

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