🎉 initial commit

This commit is contained in:
微凉
2021-10-25 18:53:59 +08:00
commit d68a4048da
10 changed files with 521 additions and 0 deletions

34
conf/config.go Normal file
View File

@ -0,0 +1,34 @@
package conf
type Database struct {
Type string `json:"type"`
User string `json:"user"`
Password string `json:"password"`
Host string `json:"host"`
Port int `json:"port"`
Name string `json:"name"`
TablePrefix string `json:"table_prefix"`
DBFile string `json:"db_file"`
}
type Config struct {
Address string `json:"address"`
Port int `json:"port"`
Database Database `json:"database"`
}
func DefaultConfig() *Config {
return &Config{
Address: "0.0.0.0",
Port: 5244,
Database: Database{
Type: "sqlite3",
User: "",
Password: "",
Host: "",
Port: 0,
Name: "",
TablePrefix: "x_",
DBFile: "data.db",
},
}
}

11
conf/var.go Normal file
View File

@ -0,0 +1,11 @@
package conf
import "gorm.io/gorm"
var (
ConfigFile string // config file
Conf *Config
Debug bool
DB *gorm.DB
)