diff --git a/README.md b/README.md index c1e5dd1..44d831d 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,15 @@ rust 项目代码 移步这里—— ## 更新日志 +- 2022-10-12 v2.0.3: + + - 优化代码逻辑 + - 优化代码报错输出内容,方便更加详细的判断是服务器错误还是工具本身的代码错误 + - 2022-10-02 v2.0.2: - - 修复search空格被吃掉的问题 - - 增加命令后颜色输出 + - 修复search空格被吃掉的问题 + - 增加命令后颜色输出 - 2022-09-28 v2.0.1: diff --git a/main.go b/main.go index c112076..8c8f880 100644 --- a/main.go +++ b/main.go @@ -73,7 +73,7 @@ func action(num int) { } switch strings.ToLower(hflag.GetString("option")) { case "version": - successColor.Println("version:2.0.2") + successColor.Println("version:2.0.3") case "init": if num < 3 { errorColor.Println("!!!!token is empty !!!!") diff --git a/utils/LoadJson.go b/utils/LoadJson.go index e144cb8..7367dab 100644 --- a/utils/LoadJson.go +++ b/utils/LoadJson.go @@ -13,12 +13,14 @@ package utils import ( "encoding/json" "fmt" + "os" ) func RespLoadJson[T any](body string) (respjson T) { if err := json.Unmarshal([]byte(body), &respjson); err != nil { fmt.Println(body) - panic(err) + //panic(err) + os.Exit(0) } return } @@ -28,9 +30,18 @@ func InfoLoadJson(body string) (data map[string]interface{}, user map[string]int var infomapjson map[string]interface{} if err := json.Unmarshal([]byte(body), &infomapjson); err != nil { fmt.Println(body) - panic(err) + //panic(err) + os.Exit(0) + } + data, ok := infomapjson["data"].(map[string]interface{}) + if !ok { + fmt.Println(infomapjson) + os.Exit(0) + } + user, ok = data["user"].(map[string]interface{}) + if !ok { + fmt.Println(infomapjson) + os.Exit(0) } - data = infomapjson["data"].(map[string]interface{}) - user = data["user"].(map[string]interface{}) return }