优化逻辑

This commit is contained in:
Yun
2024-11-10 22:28:02 +08:00
parent f66e76883f
commit 7eaf21634c
11 changed files with 54 additions and 33 deletions
+7 -1
View File
@@ -40,13 +40,19 @@ func TestError(t *testing.T) {
t.Log(val.GetCode())
}
err = langx.NewErrorFormat(ctx, "username", map[string]string{
err = langx.NewErrorf(ctx, "username", map[string]string{
"name": "yuninks",
})
t.Log(err.Error())
val, ok = err.(langx.LangError)
if ok {
t.Log(val.GetCode())
// 设置输出语言
val.SetLang("en")
}
t.Log(val.Error())
}