Skip to content

Commit 1a3df47

Browse files
committed
💚 linting
1 parent a7a5057 commit 1a3df47

5 files changed

Lines changed: 7 additions & 22 deletions

File tree

utils/maps/flatten.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func flattenMap(result Map, prefix string, v reflect.Value) (err error) {
121121
}
122122

123123
func flattenSlice(result Map, prefix string, v reflect.Value) (err error) {
124-
prefix = prefix + separator
124+
prefix += separator
125125

126126
for i := 0; i < v.Len(); i++ {
127127
subErr := flatten(result, fmt.Sprintf("%s%d", prefix, i), v.Index(i))
@@ -134,7 +134,7 @@ func flattenSlice(result Map, prefix string, v reflect.Value) (err error) {
134134
}
135135

136136
func flattenStruct(result Map, prefix string, v reflect.Value) (err error) {
137-
prefix = prefix + separator
137+
prefix += separator
138138
ty := v.Type()
139139
for i := 0; i < ty.NumField(); i++ {
140140
subErr := flatten(result, fmt.Sprintf("%s%s", prefix, ty.Field(i).Name), v.Field(i))

utils/maps/flatten_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func TestFlatten2(t *testing.T) {
204204
},
205205
},
206206
Output: map[string]string{
207-
"foo.SomeDuration": time.Duration(56 * time.Minute).String(),
207+
"foo.SomeDuration": (56 * time.Minute).String(),
208208
},
209209
},
210210
}

utils/maps/map.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (m Map) AsMap() map[string]string {
3131

3232
// Delete deletes a key out of the maps with the given prefix.
3333
func (m Map) Delete(prefix string) {
34-
for k, _ := range m {
34+
for k := range m {
3535
match := k == prefix
3636
if !match {
3737
if !strings.HasPrefix(k, prefix) {
@@ -50,7 +50,7 @@ func (m Map) Delete(prefix string) {
5050
// Keys returns all the top-level keys in this maps
5151
func (m Map) Keys() []string {
5252
ks := make(map[string]struct{})
53-
for k, _ := range m {
53+
for k := range m {
5454
idx := strings.Index(k, separator)
5555
if idx == -1 {
5656
idx = len(k)
@@ -60,7 +60,7 @@ func (m Map) Keys() []string {
6060
}
6161

6262
result := make([]string, 0, len(ks))
63-
for k, _ := range ks {
63+
for k := range ks {
6464
result = append(result, k)
6565
}
6666

utils/serialization/maps/map.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,6 @@ func toTime(f reflect.Type, t reflect.Type, data any) (any, error) {
112112
}
113113
}
114114

115-
func fromTimeDurationHookFunc() mapstructure.DecodeHookFunc {
116-
return func(
117-
f reflect.Type,
118-
t reflect.Type,
119-
data any,
120-
) (any, error) {
121-
switch f {
122-
case reflect.TypeOf(time.Duration(5)):
123-
return convertTo(f.String(), data, t)
124-
default:
125-
return data, nil
126-
}
127-
}
128-
}
129-
130115
func mapstructureDecoder(input, result any) error {
131116
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
132117
WeaklyTypedInput: true,

utils/serialization/slice/slice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package slice
33
import (
44
"github.com/ARM-software/golang-utils/utils/collection"
55
"github.com/ARM-software/golang-utils/utils/commonerrors"
6-
"github.com/ARM-software/golang-utils/utils/serialization/maps"
6+
"github.com/ARM-software/golang-utils/utils/serialization/maps" //nolint:misspell
77
)
88

99
// ToSlice converts a struct to a list of key values.

0 commit comments

Comments
 (0)