go17/book/config/config.go
2024-11-16 16:00:55 +08:00

38 lines
715 B
Go

package config
// 定义程序配置
// dsn := "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8mb4&parseTime=True&loc=Local"
// 凡是可以提出出配置的
// 程序的配置对象
type Config struct {
App `json:"app"`
MySQL `json:"mysql"`
}
// app:
//
// host: 127.0.0.1
// port: 8080
type App struct {
Host string `json:"host"`
Port int `json:"port"`
}
// mysql:
//
// host: 127.0.0.1
// port: 3306
// database: test
// username: "root"
// password: "123456"
// debug: true
type MySQL struct {
Host string `json:"host"`
Port int `json:"port"`
Database string `json:"database"`
Username string `json:"username"`
Password string `json:"password"`
Debug bool `json:"debug"`
}