From 8a124c4a87cce201242bbd7abb67660278795233 Mon Sep 17 00:00:00 2001 From: kakj-go <18579115540@163.com> Date: Tue, 21 Dec 2021 10:30:35 +0800 Subject: [PATCH] If it is a MAC system, skip the global configuration internationalization information --- 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()