Skip to content

Commit

Permalink
add inject debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
cpunion committed Nov 20, 2024
1 parent 68f90fd commit fc95654
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit fc95654

Please sign in to comment.