# 配置

项目配置文件为项目运行必须文件,不配置无法运行,快速配置可以复制"config.example"重命名 "config.yaml"。具体配置如下

env: "dev" # 环境配置
db: #数据库配置
  type: 'mysql' 
  host: '127.0.0.1' 
  port: '3306'
  max-idle-conns: 10
  max-open-conns: 100
  name: 'root'
  password: ''
  database: 'gin_scuiadmin'
  table_prefix: 'gc_'

myjwt:#jwt认证配置密钥
  secret: '1212121213131'
app:#项目相关的配置
  host: "http://localhost:8080"
  port: ":8080"
  uploadFile: "/upload"
rate: #限流配置
  limit: 15
  burst: 2
logger:
  drive: "zap" # 日志记录驱动
  path: "logs" # 日志存放路径
  size: 10 # 日志大小
  maxAge: 3 #日志保留天数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

注意
如果要自己扩展额外的配置项,需要要在对应的common.go文件里增加结构体属性.

config/common.go文件如下

type Config struct {
	Db struct {
		Type         string `yaml:"type"`
		MaxIdleConns int    `yaml:"max-idle-conns"`
		MaxOpenConns int    `yaml:"max-open-conns"`
		Port         string `yaml:"port"`
		Host         string `yaml:"host"`
		TablePrefix  string `yaml:"table_prefix"`
		Database     string `yaml:"database"`
		User         string `yaml:"name"`
		PassWord     string `yaml:"password"`
	}
	MyJwt struct {
		Secret string `yaml:"secret"`
	}
	App struct {
		Host       string `yaml:"host"`
		Port       string `yaml:"port"`
		UploadFile string `yaml:"uploadFile"`
	}
	Rate struct {
		Limit rate.Limit `yaml:"limit"`
		Burst int        `yaml:"burst"`
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25