clear:formatting code

This commit is contained in:
zhangwenjian
2020-07-23 12:03:17 +08:00
parent 426cec1b62
commit 8c554d7ee7
52 changed files with 486 additions and 502 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ func portDefault(cfg *viper.Viper) string {
}
func isHttpsDefault(cfg *viper.Viper) bool {
if cfg.GetString("ishttps") == "" || cfg.GetBool("ishttps") == false{
if cfg.GetString("ishttps") == "" || cfg.GetBool("ishttps") == false {
return false
} else {
return true
-3
View File
@@ -16,7 +16,6 @@ var cfgLog *viper.Viper
var cfgSsl *viper.Viper
var cfgGen *viper.Viper
//载入配置文件
func ConfigSetup(path string) {
viper.SetConfigFile(path)
@@ -25,7 +24,6 @@ func ConfigSetup(path string) {
log.Fatal(fmt.Sprintf("Read config file fail: %s", err.Error()))
}
//Replace environment variables
err = viper.ReadConfig(strings.NewReader(os.ExpandEnv(string(content))))
if err != nil {
@@ -69,7 +67,6 @@ func ConfigSetup(path string) {
GenConfig = InitGen(cfgGen)
}
func SetConfig(configPath string, key string, value interface{}) {
viper.AddConfigPath(configPath)
viper.Set(key, value)
-1
View File
@@ -19,4 +19,3 @@ func InitDatabase(cfg *viper.Viper) *Database {
}
var DatabaseConfig = new(Database)
+4 -4
View File
@@ -3,14 +3,14 @@ package config
import "github.com/spf13/viper"
type Gen struct {
DBName string
FrontPath string
DBName string
FrontPath string
}
func InitGen(cfg *viper.Viper) *Gen {
return &Gen{
DBName: cfg.GetString("dbname"),
FrontPath: cfg.GetString("frontpath"),
DBName: cfg.GetString("dbname"),
FrontPath: cfg.GetString("frontpath"),
}
}
+2 -2
View File
@@ -3,13 +3,13 @@ package config
import "github.com/spf13/viper"
type Log struct {
Dir string
Dir string
Operdb bool
}
func InitLog(cfg *viper.Viper) *Log {
return &Log{
Dir: cfg.GetString("dir"),
Dir: cfg.GetString("dir"),
Operdb: cfg.GetBool("operdb"),
}
}