优化逻辑

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
+17
View File
@@ -0,0 +1,17 @@
package langx
import "context"
const ctxLangKey string = "ctxLang"
func SetCtxLang(ctx context.Context, lang string) context.Context {
return context.WithValue(ctx, ctxLangKey, lang)
}
func GetCtxLang(ctx context.Context) string {
lang, ok := ctx.Value(ctxLangKey).(string)
if !ok {
return ""
}
return lang
}