Ignore comment lines and lines full o' whitespace.

This commit is contained in:
John Barton (joho)
2013-07-31 12:37:08 +10:00
parent 48ca995c3b
commit 9001b88250
2 changed files with 30 additions and 6 deletions

View File

@ -42,10 +42,12 @@ func loadFile(filename string) (err error) {
}
for _, fullLine := range lines {
key, value, err := parseLine(fullLine)
if !isIgnoredLine(fullLine) {
key, value, err := parseLine(fullLine)
if err == nil {
os.Setenv(key, value)
if err == nil {
os.Setenv(key, value)
}
}
}
@ -116,3 +118,8 @@ func parseLine(line string) (key string, value string, err error) {
return
}
func isIgnoredLine(line string) bool {
trimmedLine := strings.Trim(line, " \n\t")
return len(trimmedLine) == 0 || strings.HasPrefix(trimmedLine, "#")
}