From fc956541019328bdf67f8a412a83842bbc487745 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Wed, 20 Nov 2024 22:57:14 +0800 Subject: [PATCH] add inject debug log --- inject.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/inject.go b/inject.go index 5bb660f..95f37df 100644 --- a/inject.go +++ b/inject.go @@ -10,13 +10,21 @@ import ( var ProjectRoot string func init() { + injectDebug := os.Getenv("INJECT_DEBUG") if ProjectRoot == "" { - panic("ProjectRoot is not set, compile with -ldflags '-X github.com/cpunion/go-python.ProjectRoot=/path/to/project/.deps'") + panic("ProjectRoot is not set, compile with -ldflags '-X github.com/cpunion/go-python.ProjectRoot=/path/to/project'") } envs, err := env.ReadEnv(ProjectRoot) if err != nil { panic(fmt.Sprintf("Failed to read env: %s", err)) } + if injectDebug != "" { + fmt.Fprintf(os.Stderr, "Injecting envs for project: %s\n", ProjectRoot) + for key, value := range envs { + fmt.Fprintf(os.Stderr, " %s=%s\n", key, value) + } + fmt.Fprintf(os.Stderr, "End of envs\n") + } for key, value := range envs { os.Setenv(key, value) }