Skip to content

Commit f1bbf57

Browse files
committed
more lint fixes
1 parent 0dc11f9 commit f1bbf57

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

map.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cnfg
22

33
import (
4+
"maps"
45
"reflect"
56
"strings"
67
)
@@ -32,9 +33,7 @@ func (p Pairs) Set(k, v string) {
3233

3334
// Merge merges two Pairs maps.
3435
func (p Pairs) Merge(pairs Pairs) {
35-
for k, v := range pairs {
36-
p[k] = v
37-
}
36+
maps.Copy(p, pairs)
3837
}
3938

4039
// UnmarshalMap parses and processes a map of key/value pairs as though they

parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (p *parser) Struct(field reflect.Value, prefix string) (bool, error) {
2626
var exitOk bool
2727

2828
t := field.Type().Elem()
29-
for idx := 0; idx < t.NumField(); idx++ { // Loop each struct member
29+
for idx := range t.NumField() { // Loop each struct member
3030
tagval := strings.Split(t.Field(idx).Tag.Get(p.Tag), ",")
3131
shorttag := tagval[0]
3232

unparse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (p *unparser) DeconStruct(field reflect.Value, prefix string) (Pairs, error
2020
output := Pairs{}
2121

2222
element := field.Type().Elem()
23-
for idx := 0; idx < element.NumField(); idx++ { // Loop each struct member
23+
for idx := range element.NumField() { // Loop each struct member
2424
tagval := strings.Split(element.Field(idx).Tag.Get(p.Tag), ",")
2525
tag := tagval[0]
2626

@@ -227,7 +227,7 @@ func (p *unparser) SliceValue(field reflect.Value, tag string, omitempty bool) (
227227
output := Pairs{}
228228

229229
total := field.Len()
230-
for i := 0; i < total; i++ {
230+
for i := range total {
231231
ntag := strings.Join([]string{tag, strconv.Itoa(i)}, LevelSeparator)
232232
value := reflect.Indirect(field.Index(i).Addr())
233233

0 commit comments

Comments
 (0)