package
1.0.1
Repository: https://github.com/cube-group/golib.git
Documentation: pkg.go.dev

# README

conf.Init

conf.Init会自动解析application.yaml中的redis和mysql配置

//直接读取远程yaml配置文件
conf.Init(conf.Template{
	AppYamlPath: "https://eoffcn-software.oss-cn-beijing.aliyuncs.com/application.yaml",
})

//读取本地yaml配置文件
conf.Init(conf.Template{
	AppYamlPath: "/conf/application.yaml",
})

redis配置

yaml单链接配置

redis:
  address: 127.0.0.1:6379
  password: 
  db: 0
  poolSize: 2

单连接实例:

conf.Redis().Set("a","1",time.Minute)

yaml多链接配置

redis:
  default:
    address: 127.0.0.1:6379
    password: 
    db: 0
    poolSize: 2
  other:
    address: 127.0.0.1:6378
    password: 
    db: 0
    poolSize: 2

多连接实例:

conf.Redis("default").Set("a","1",time.Minute)
//与下方链接一致
//conf.Redis().Set("a","1",time.Minute)

conf.Redis("other").Set("a","2",time.Minute)

mysql配置

yaml单链接配置

mysql:
  address: root:root@tcp(127.0.0.1:3306)/demo?charset=utf8&parseTime=True&loc=Local
  maxIdle: 5
  maxOpen: 100
  logMode: true

单连接实例:

conf.DB().Exec("show databases").Error

yaml多链接配置

mysql:
  default:
    address: root:root@tcp(127.0.0.1:3306)/demo?charset=utf8&parseTime=True&loc=Local
    maxIdle: 5
    maxOpen: 100
    logMode: true
  other:
    address: root:root@tcp(127.0.0.1:3307)/demo?charset=utf8&parseTime=True&loc=Local
    maxIdle: 5
    maxOpen: 100
    logMode: true

多连接实例:

conf.DB().Exec("show databases").Error
//与下方链接一致
//conf.DB("default").Exec("show databases").Error

conf.DB("other").Exec("show databases").Error

# Functions

No description provided by the author
错误是否为.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
初始化配置模板.