瀏覽代碼

修复读取配置文件错误

zhangjq 6 年之前
父節點
當前提交
bd129e4065
共有 4 個文件被更改,包括 10 次插入4 次删除
  1. 2 1
      config/config.go
  2. 4 0
      logs/logs.go
  3. 2 2
      utils/pwd.go
  4. 2 1
      utils/store.go

+ 2 - 1
config/config.go

@@ -18,7 +18,8 @@ func init()  {
 }
 
 func ParseConfig()  {
-	_config, err := LoadConfiguration("conf/app.conf")
+	var err error
+	_config, err = LoadConfiguration("conf/app.conf")
 	if err != nil{
 		fmt.Println(err.Error())
 		AppConfig.AppName = ""

+ 4 - 0
logs/logs.go

@@ -1,5 +1,9 @@
 package logs
 
+import (
+	"fmt"
+)
+
 func Error(v ...interface{})  {
 	fmt.Println(v)
 }

+ 2 - 2
utils/pwd.go

@@ -16,9 +16,9 @@ import (
 
 func HashPassword(password, salt string) string {
 	h := md5.New()
-	enableDbSalt, _ := config.AppConfig.GetBool("System::EnableDBSalt", true)
+	enableDbSalt := config.AppConfig.GetBool("System::EnableDBSalt", true)
 	customSalt := config.AppConfig.GetKey("System::PasswordSalt")
-	enableBase64, _ := config.AppConfig.GetBool("System::PasswordEnableBase64", true)
+	enableBase64 := config.AppConfig.GetBool("System::PasswordEnableBase64", true)
 	if !enableDbSalt {
 		h.Write([]byte(password))
 		if len(customSalt) > 0 {

+ 2 - 1
utils/store.go

@@ -6,6 +6,7 @@ import (
 	"time"
 
 	"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/config"
 )
 
 type TokenStore struct {
@@ -61,7 +62,7 @@ func (t *TokenStore) Refresh(key string) {
 }
 
 func (t *TokenStore) startTokenCheckProcess() {
-	autoRefresh, _ := NewConfig().Bool("auto_refresh", false)
+	autoRefresh := config.AppConfig.GetBool("auto_refresh", false)
 	if !autoRefresh {
 		return
 	}