config

package
v0.0.0-...-a1cb33f Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBMaxOpenConns = 100
View Source
var StartTime time.Time = time.Now()

Functions

func Defer

func Defer()

执行程序清理 defer关闭前执行的close操作

func Init

func Init()

包应该被引入就立即执行初始化操作 方便阅读所以在main中显式执行 某些场景下有些业务不需要

func InitCache

func InitCache() error

func InitEnv

func InitEnv() error

从env赋值为Cfg实例

func InitGorm

func InitGorm() error

设置gorm数据库的实例

func InitLogger

func InitLogger() error

处理日志实例

func Listen

func Listen() string

func Secret

func Secret() []byte

Types

type Badger

type Badger struct {
	Dsn string // 缓存连接信息
}

type Cache

type Cache struct {
	Dsn string // 缓存连接信息
}

type CfgMode

type CfgMode int
const (
	ModeDev CfgMode = iota
	ModeProd
)

func Mode

func Mode() CfgMode

type Config

type Config struct {
	Listen string  // Http Listen Addr
	Secret string  // 加密中的盐
	Mode   CfgMode // 配置的app模式

	Logger   Logger   // 日志的处理
	Database Database // 数据库配置信息
	Cache    Cache    // 缓存配置信息
}

type Database

type Database struct {
	Dsn string // 数据库连接信息
}

type Logger

type Logger struct {
	Dsn   string          // 日志处理方式,可以写入文件或者队列
	Level logger.LogLevel // 数据库日志级别
}

Jump to

Keyboard shortcuts

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