summaryrefslogtreecommitdiff
path: root/addpath.go
blob: 22f6c1ecb075ca7d5da57425b7e0c82a711a773d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
}