@@ -21,20 +21,20 @@ const (
21
21
)
22
22
23
23
var (
24
- ErrMalformedIndex = errors .New ("Malformed index key" )
25
- ErrInvalidIndexUsage = errors .New ("Invalid index key usage" )
26
- ErrKeyNotFound = errors .New ("Unable to find the key" )
24
+ ErrMalformedIndex = errors .New ("malformed index key" )
25
+ ErrInvalidIndexUsage = errors .New ("invalid index key usage" )
26
+ ErrKeyNotFound = errors .New ("unable to find the key" )
27
27
)
28
28
29
29
// LookupString performs a lookup into a value, using a string. Same as `Lookup`
30
30
// but using a string with the keys separated by `.`
31
- func LookupString (i interface {} , path string , tags []string ) (reflect.Value , error ) {
31
+ func LookupString (i any , path string , tags []string ) (reflect.Value , error ) {
32
32
return Lookup (i , strings .Split (path , SplitToken ), tags )
33
33
}
34
34
35
35
// LookupStringI is the same as LookupString, but the path is not case
36
36
// sensitive.
37
- func LookupStringI (i interface {} , path string , tags []string ) (reflect.Value , error ) {
37
+ func LookupStringI (i any , path string , tags []string ) (reflect.Value , error ) {
38
38
return LookupI (i , strings .Split (path , SplitToken ), tags )
39
39
}
40
40
@@ -44,16 +44,16 @@ func LookupStringI(i interface{}, path string, tags []string) (reflect.Value, er
44
44
// If one key owns to a slice and an index is not
45
45
// specified the rest of the path will be applied to eval value of the
46
46
// slice, and the value will be merged into a slice.
47
- func Lookup (i interface {} , path []string , tags []string ) (reflect.Value , error ) {
47
+ func Lookup (i any , path []string , tags []string ) (reflect.Value , error ) {
48
48
return lookup (i , false , path , tags )
49
49
}
50
50
51
51
// LookupI is the same as Lookup, but the path keys are not case sensitive.
52
- func LookupI (i interface {} , path []string , tags []string ) (reflect.Value , error ) {
52
+ func LookupI (i any , path []string , tags []string ) (reflect.Value , error ) {
53
53
return lookup (i , true , path , tags )
54
54
}
55
55
56
- func SetValueStringI [V int64 | int | string | bool | reflect.Value ](i interface {} , v V , path string , tags []string ) error {
56
+ func SetValueStringI [V int64 | int | string | bool | reflect.Value ](i any , v V , path string , tags []string ) error {
57
57
// First find the variable
58
58
dest , err := Lookup (i , strings .Split (path , SplitToken ), tags )
59
59
if err != nil {
@@ -86,7 +86,7 @@ func SetValueStringI[V int64 | int | string | bool | reflect.Value](i interface{
86
86
return nil
87
87
}
88
88
89
- func lookup (i interface {} , caseInsensitive bool , path []string , tags []string ) (reflect.Value , error ) {
89
+ func lookup (i any , caseInsensitive bool , path []string , tags []string ) (reflect.Value , error ) {
90
90
value := reflect .ValueOf (i )
91
91
var parent reflect.Value
92
92
var err error
@@ -275,7 +275,7 @@ func isMergeable(v reflect.Value) bool {
275
275
}
276
276
277
277
func hasIndex (s string ) bool {
278
- return strings .Index (s , IndexOpenChar ) != - 1
278
+ return strings .Contains (s , IndexOpenChar )
279
279
}
280
280
281
281
func parseIndex (s string ) (string , int , error ) {
0 commit comments