From 53400d221c37ee1ec495821aa5411e061af0f223 Mon Sep 17 00:00:00 2001 From: kakj <18579115540@163.com> Date: Tue, 21 Dec 2021 14:26:59 +0800 Subject: [PATCH] If it is a MAC system, skip the global configuration internationalization information (#3429) --- pkg/i18n/helper.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/i18n/helper.go b/pkg/i18n/helper.go index 55a195bd132..233101abc8e 100644 --- a/pkg/i18n/helper.go +++ b/pkg/i18n/helper.go @@ -17,6 +17,7 @@ package i18n import ( "context" "net/http" + "runtime" "github.com/erda-project/erda/pkg/goroutine_context" ) @@ -41,6 +42,11 @@ func GetLocaleNameByRequest(request *http.Request) string { } func GetGoroutineBindLang() string { + // mac system use goroutine_context.GetContext() will panic + if runtime.GOOS == "darwin" { + return "" + } + globalContext := goroutine_context.GetContext() if globalContext == nil { return "" @@ -58,6 +64,11 @@ func GetGoroutineBindLang() string { } func SetGoroutineBindLang(localeName string) { + // mac system use goroutine_context.GetContext() will panic + if runtime.GOOS == "darwin" { + return + } + ctx := goroutine_context.GetContext() if ctx == nil { ctx = context.Background()