new
This commit is contained in:
@@ -2,17 +2,17 @@ package config
|
||||
|
||||
import "fmt"
|
||||
|
||||
//
|
||||
//Config .
|
||||
type Config struct {
|
||||
CfgBase
|
||||
MySQLInfo MysqlDbInfo `toml:"mysql_info"`
|
||||
OutDir string `toml:"out_dir"`
|
||||
Simple bool `toml:"simple"`
|
||||
IsJsonTag bool `toml:"isJsonTag"`
|
||||
IsJSONTag bool `toml:"isJsonTag"`
|
||||
SingularTable bool `toml:"singular_table"`
|
||||
}
|
||||
|
||||
//mysql 数据库信息
|
||||
//MysqlDbInfo mysql 数据库信息
|
||||
type MysqlDbInfo struct {
|
||||
Host string `validate:"required"` //地址
|
||||
Port int `validate:"required"` //端口号
|
||||
@@ -21,17 +21,17 @@ type MysqlDbInfo struct {
|
||||
Database string `validate:"required"` //数据库名
|
||||
}
|
||||
|
||||
//更新mysql配置信息
|
||||
//SetMysqlDbInfo 更新mysql配置信息
|
||||
func SetMysqlDbInfo(info *MysqlDbInfo) {
|
||||
_map.MySQLInfo = *info
|
||||
}
|
||||
|
||||
//获取mysql配置信息
|
||||
//GetMysqlDbInfo 获取mysql配置信息
|
||||
func GetMysqlDbInfo() MysqlDbInfo {
|
||||
return _map.MySQLInfo
|
||||
}
|
||||
|
||||
//获取mysql 连接字符串
|
||||
//GetMysqlConStr 获取mysql 连接字符串
|
||||
func GetMysqlConStr() string {
|
||||
return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local",
|
||||
_map.MySQLInfo.Username,
|
||||
@@ -42,32 +42,32 @@ func GetMysqlConStr() string {
|
||||
)
|
||||
}
|
||||
|
||||
//设置输出目录
|
||||
//SetOutDir 设置输出目录
|
||||
func SetOutDir(outDir string) {
|
||||
_map.OutDir = outDir
|
||||
}
|
||||
|
||||
//获取输出目录
|
||||
//GetOutDir 获取输出目录
|
||||
func GetOutDir() string {
|
||||
return _map.OutDir
|
||||
}
|
||||
|
||||
//设置禁用表名复数
|
||||
//SetSingularTable 设置禁用表名复数
|
||||
func SetSingularTable(b bool) {
|
||||
_map.SingularTable = b
|
||||
}
|
||||
|
||||
//获取禁用表名复数
|
||||
//GetSingularTable 获取禁用表名复数
|
||||
func GetSingularTable() bool {
|
||||
return _map.SingularTable
|
||||
}
|
||||
|
||||
//简单输出
|
||||
//GetSimple 简单输出
|
||||
func GetSimple() bool {
|
||||
return _map.Simple
|
||||
}
|
||||
|
||||
//json标记
|
||||
func GetIsJsonTag() bool {
|
||||
return _map.IsJsonTag
|
||||
//GetIsJSONTag json标记
|
||||
func GetIsJSONTag() bool {
|
||||
return _map.IsJSONTag
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
//
|
||||
//CfgBase .
|
||||
type CfgBase struct {
|
||||
SerialNumber string `json:"serial_number" toml:"serial_number"` //版本号
|
||||
ServiceName string `json:"service_name" toml:"service_name"` //service名字
|
||||
@@ -44,7 +44,7 @@ func InitFile(filename string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//获取service配置信息
|
||||
//GetServiceConfig 获取service配置信息
|
||||
func GetServiceConfig() (name, displayName, desc string) {
|
||||
name = _map.ServiceName
|
||||
displayName = _map.ServiceDisplayname
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
test_file = `
|
||||
testFile = `
|
||||
`
|
||||
)
|
||||
|
||||
//判断是否在测试环境下使用
|
||||
//IsRunTesting 判断是否在测试环境下使用
|
||||
func IsRunTesting() bool {
|
||||
if len(os.Args) > 1 {
|
||||
return strings.HasPrefix(os.Args[1], "-test")
|
||||
|
||||
Reference in New Issue
Block a user