Skip to content

Commit 8d2efb3

Browse files
committed
renamed New -> NewMap
1 parent 109e9f3 commit 8d2efb3

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

properties.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ func init() {
9999
}
100100
}
101101

102-
// New returns a new Map
103-
func New() *Map {
102+
// NewMap returns a new Map
103+
func NewMap() *Map {
104104
return &Map{
105105
kv: map[string]string{},
106106
o: []string{},
@@ -118,7 +118,7 @@ func Load(filepath string) (*Map, error) {
118118
text = strings.Replace(text, "\r\n", "\n", -1)
119119
text = strings.Replace(text, "\r", "\n", -1)
120120

121-
properties := New()
121+
properties := NewMap()
122122

123123
for lineNum, line := range strings.Split(text, "\n") {
124124
if err := properties.parseLine(line); err != nil {
@@ -137,7 +137,7 @@ func LoadFromPath(path *paths.Path) (*Map, error) {
137137
// LoadFromSlice reads a properties file from an array of string
138138
// and makes a Map out of it
139139
func LoadFromSlice(lines []string) (*Map, error) {
140-
properties := New()
140+
properties := NewMap()
141141

142142
for lineNum, line := range lines {
143143
if err := properties.parseLine(line); err != nil {
@@ -180,7 +180,7 @@ func SafeLoadFromPath(path *paths.Path) (*Map, error) {
180180
func SafeLoad(filepath string) (*Map, error) {
181181
_, err := os.Stat(filepath)
182182
if os.IsNotExist(err) {
183-
return New(), nil
183+
return NewMap(), nil
184184
}
185185

186186
properties, err := Load(filepath)
@@ -273,7 +273,7 @@ func (m *Map) FirstLevelOf() map[string]*Map {
273273
}
274274
keyParts := strings.SplitN(key, ".", 2)
275275
if newMap[keyParts[0]] == nil {
276-
newMap[keyParts[0]] = New()
276+
newMap[keyParts[0]] = NewMap()
277277
}
278278
value := m.kv[key]
279279
newMap[keyParts[0]].Set(keyParts[1], value)
@@ -307,7 +307,7 @@ func (m *Map) FirstLevelOf() map[string]*Map {
307307
// },
308308
func (m *Map) SubTree(rootKey string) *Map {
309309
rootKey += "."
310-
newMap := New()
310+
newMap := NewMap()
311311
for _, key := range m.o {
312312
if !strings.HasPrefix(key, rootKey) {
313313
continue
@@ -371,7 +371,7 @@ func (m Map) Values() []string {
371371

372372
// Clone makes a copy of the Map
373373
func (m *Map) Clone() *Map {
374-
clone := New()
374+
clone := NewMap()
375375
clone.Merge(m)
376376
return clone
377377
}

properties_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func TestPropertiesTestTxt(t *testing.T) {
7373
}
7474

7575
func TestExpandPropsInString(t *testing.T) {
76-
aMap := New()
76+
aMap := NewMap()
7777
aMap.Set("key1", "42")
7878
aMap.Set("key2", "{key1}")
7979

@@ -84,7 +84,7 @@ func TestExpandPropsInString(t *testing.T) {
8484
}
8585

8686
func TestExpandPropsInString2(t *testing.T) {
87-
p := New()
87+
p := NewMap()
8888
p.Set("key2", "{key2}")
8989
p.Set("key1", "42")
9090

@@ -95,7 +95,7 @@ func TestExpandPropsInString2(t *testing.T) {
9595
}
9696

9797
func TestDeleteUnexpandedPropsFromString(t *testing.T) {
98-
p := New()
98+
p := NewMap()
9999
p.Set("key1", "42")
100100
p.Set("key2", "{key1}")
101101

@@ -107,7 +107,7 @@ func TestDeleteUnexpandedPropsFromString(t *testing.T) {
107107
}
108108

109109
func TestDeleteUnexpandedPropsFromString2(t *testing.T) {
110-
p := New()
110+
p := NewMap()
111111
p.Set("key2", "42")
112112

113113
str := "{key1} == {key2} == {key3} == true"
@@ -132,7 +132,7 @@ func TestPropertiesRedBeearLabBoardsTxt(t *testing.T) {
132132
}
133133

134134
func TestSubTreeForMultipleDots(t *testing.T) {
135-
p := New()
135+
p := NewMap()
136136
p.Set("root.lev1.prop", "hi")
137137
p.Set("root.lev1.prop2", "how")
138138
p.Set("root.lev1.prop3", "are")
@@ -153,7 +153,7 @@ func TestPropertiesBroken(t *testing.T) {
153153
}
154154

155155
func TestGetSetBoolean(t *testing.T) {
156-
m := New()
156+
m := NewMap()
157157
m.Set("a", "true")
158158
m.Set("b", "false")
159159
m.Set("c", "hello")
@@ -171,7 +171,7 @@ func TestGetSetBoolean(t *testing.T) {
171171
}
172172

173173
func TestKeysMethod(t *testing.T) {
174-
m := New()
174+
m := NewMap()
175175
m.Set("k1", "value")
176176
m.Set("k2", "othervalue")
177177
m.Set("k3.k4", "anothevalue")

0 commit comments

Comments
 (0)