Skip to content

Commit 7c4d1df

Browse files
committed
inject github.com/cpunion/go-python.ProjectRoot variable
1 parent 7f748b3 commit 7c4d1df

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

inject.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package gp
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/cpunion/go-python/internal/env"
8+
)
9+
10+
var ProjectRoot string
11+
12+
func init() {
13+
if ProjectRoot == "" {
14+
fmt.Fprintf(os.Stderr, "ProjectRoot is not set\n")
15+
return
16+
}
17+
envs, err := env.ReadEnv(ProjectRoot)
18+
if err != nil {
19+
fmt.Fprintf(os.Stderr, "Failed to read env: %s\n", err)
20+
return
21+
}
22+
for key, value := range envs {
23+
os.Setenv(key, value)
24+
}
25+
}

0 commit comments

Comments
 (0)