From 59effd5ceba6f28e2bc2edd2b927abb4556f63b5 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 27 Oct 2025 20:38:47 -0500 Subject: add paths to the shell ENV PATH --- addpath.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 addpath.go (limited to 'addpath.go') 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 +} -- cgit v1.2.3