@@ -68,7 +68,7 @@ func Load(filepath string) (Map, error) {
68
68
properties := make (Map )
69
69
70
70
for lineNum , line := range strings .Split (text , "\n " ) {
71
- if err := properties .loadSingleLine (line ); err != nil {
71
+ if err := properties .parseLine (line ); err != nil {
72
72
return nil , fmt .Errorf ("Error reading file (%s:%d): %s" , filepath , lineNum , err )
73
73
}
74
74
}
@@ -80,17 +80,18 @@ func LoadFromSlice(lines []string) (Map, error) {
80
80
properties := make (Map )
81
81
82
82
for lineNum , line := range lines {
83
- if err := properties .loadSingleLine (line ); err != nil {
83
+ if err := properties .parseLine (line ); err != nil {
84
84
return nil , fmt .Errorf ("Error reading from slice (index:%d): %s" , lineNum , err )
85
85
}
86
86
}
87
87
88
88
return properties , nil
89
89
}
90
90
91
- func (properties Map ) loadSingleLine (line string ) error {
91
+ func (m Map ) parseLine (line string ) error {
92
92
line = strings .TrimSpace (line )
93
93
94
+ // Skip empty lines or comments
94
95
if len (line ) == 0 || line [0 ] == '#' {
95
96
return nil
96
97
}
@@ -103,7 +104,7 @@ func (properties Map) loadSingleLine(line string) error {
103
104
value := strings .TrimSpace (lineParts [1 ])
104
105
105
106
key = strings .Replace (key , "." + osSuffix , "" , 1 )
106
- properties [key ] = value
107
+ m [key ] = value
107
108
108
109
return nil
109
110
}
0 commit comments