diff options
| author | Jeff Carr <[email protected]> | 2025-10-27 20:38:47 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-27 20:38:47 -0500 |
| commit | 59effd5ceba6f28e2bc2edd2b927abb4556f63b5 (patch) | |
| tree | 0f4432adf020cce99e68ac96b549a25a39310e65 | |
| parent | 5737a6e3f362716b62cfff6607c5b81daf1ef87e (diff) | |
add paths to the shell ENV PATHv0.0.10
| -rw-r--r-- | addpath.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/addpath.go b/addpath.go new file mode 100644 index 0000000..22f6c1e --- /dev/null +++ b/addpath.go @@ -0,0 +1,27 @@ +package env + +import ( + "os" + "strings" + + "go.wit.com/log" +) + +// this is an experiment at this point to +// see how this turns out + +// adds a path to the ENV +func AddPath(newpath string) bool { + path := os.Getenv("PATH") + for _, p := range strings.Split(path, ":") { + log.Info("Looking at path:", p) + if p == newpath { + log.Info("FOUND path:", p) + return false + } + } + path = path + ":" + newpath + log.Info("ADDING PATH:", path) + os.Setenv("PATH", path) + return true +} |
