更新例子

This commit is contained in:
Yun
2024-07-06 18:26:23 +08:00
parent 2878b5fa7d
commit 7e9199ad93
+10
View File
@@ -19,6 +19,7 @@ func TestError(t *testing.T) {
langx.RegisterCode(map[string]int{
"login_success": 200,
"error": 400,
"username": 201,
})
langx.RegisterTrans("zh", map[string]string{
"login_success": "成功",
@@ -39,4 +40,13 @@ func TestError(t *testing.T) {
t.Log(val.Code())
}
err = langx.NewErrorFormat(ctx, "username", map[string]string{
"name": "yuninks",
})
t.Log(err.Error())
val, ok = err.(*langx.LangError)
if ok {
t.Log(val.Code())
}
}