gxap

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package gxap 内部公共代码

Package gxap 项目内公用工具类

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePath

func CreatePath(dir string) error

CreatePath 创建目录

func PathExist

func PathExist(f string) bool

Types

type Conf

type Conf struct {
	Profiles string    `yaml:"profiles"`
	Log      confLog   `yaml:"log"`
	Db       confDb    `yaml:"db"`
	Redis    confRedis `yaml:"redis"`
}

Conf 配置文件格式

type Ctx

type Ctx struct {
	Config  Conf
	Db      *gorm.DB
	Log     *zap.SugaredLogger
	SysPath SysPath
	Redis   IRed
}

Ctx 环境

func Context added in v0.0.3

func Context() *Ctx

func (*Ctx) Close

func (ctx *Ctx) Close()

func (*Ctx) GetConfig added in v0.0.3

func (ctx *Ctx) GetConfig() Conf

func (*Ctx) GetDb added in v0.0.3

func (ctx *Ctx) GetDb() *gorm.DB

func (*Ctx) GetLog added in v0.0.3

func (ctx *Ctx) GetLog() *zap.SugaredLogger

func (*Ctx) GetRedis added in v0.0.3

func (ctx *Ctx) GetRedis() IRed

func (*Ctx) GetSysPath added in v0.0.3

func (ctx *Ctx) GetSysPath() SysPath

func (*Ctx) InitDb

func (ctx *Ctx) InitDb()

InitDb 连接数据库

func (*Ctx) InitLog

func (ctx *Ctx) InitLog()

func (*Ctx) InitRedis

func (ctx *Ctx) InitRedis()

InitRedis 连接redis

func (*Ctx) InitSysConfig

func (ctx *Ctx) InitSysConfig()

func (*Ctx) LoadConfig

func (ctx *Ctx) LoadConfig(confOut interface{})

func (*Ctx) LogWriter

func (ctx *Ctx) LogWriter(name string) io.Writer

func (*Ctx) RedisClose

func (ctx *Ctx) RedisClose()

RedisClose 关闭redis客户端

func (*Ctx) SignalListen

func (ctx *Ctx) SignalListen(callback func(s os.Signal))

type ICtx added in v0.0.3

type ICtx interface {
	GetConfig() Conf
	GetDb() *gorm.DB
	GetLog() *zap.SugaredLogger
	GetSysPath() SysPath
	GetRedis() IRed
	Close()
}

type IRed added in v0.0.3

type IRed interface {
	redis.Cmdable
	io.Closer
}

type SysPath added in v0.0.3

type SysPath struct {
	CurDir    string
	ConfigDir string
}

Jump to

Keyboard shortcuts

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