Skip to content

Commit 5247c5f

Browse files
committed
add inject debug log
1 parent 68f90fd commit 5247c5f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

inject.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,24 @@ import (
1010
var ProjectRoot string
1111

1212
func init() {
13+
injectDebug := os.Getenv("GP_INJECT_DEBUG")
1314
if ProjectRoot == "" {
14-
panic("ProjectRoot is not set, compile with -ldflags '-X github.com/cpunion/go-python.ProjectRoot=/path/to/project/.deps'")
15+
if injectDebug != "" {
16+
panic("ProjectRoot is not set, compile with -ldflags '-X github.com/cpunion/go-python.ProjectRoot=/path/to/project'")
17+
}
18+
return
1519
}
1620
envs, err := env.ReadEnv(ProjectRoot)
1721
if err != nil {
1822
panic(fmt.Sprintf("Failed to read env: %s", err))
1923
}
24+
if injectDebug != "" {
25+
fmt.Fprintf(os.Stderr, "Injecting envs for project: %s\n", ProjectRoot)
26+
for key, value := range envs {
27+
fmt.Fprintf(os.Stderr, " %s=%s\n", key, value)
28+
}
29+
fmt.Fprintf(os.Stderr, "End of envs\n")
30+
}
2031
for key, value := range envs {
2132
os.Setenv(key, value)
2233
}

0 commit comments

Comments
 (0)