@@ -3,6 +3,7 @@ package structs
33import (
44 "errors"
55 "reflect"
6+ "strings"
67)
78
89// CallbackFunc on the struct field
@@ -58,18 +59,18 @@ func FilterStruct[T any](input T, includeFields, excludeFields []string) (T, err
5859 excludeMap := make (map [string ]bool )
5960
6061 for _ , field := range includeFields {
61- includeMap [field ] = true
62+ includeMap [strings . ToLower ( field ) ] = true
6263 }
6364 for _ , field := range excludeFields {
64- excludeMap [field ] = true
65+ excludeMap [strings . ToLower ( field ) ] = true
6566 }
6667
6768 typeOfStruct := val .Type ()
6869 filteredStruct := reflect .New (typeOfStruct ).Elem ()
6970
7071 for i := 0 ; i < val .NumField (); i ++ {
7172 field := typeOfStruct .Field (i )
72- fieldName := field .Name
73+ fieldName := strings . ToLower ( field .Name )
7374 fieldValue := val .Field (i )
7475
7576 if (len (includeMap ) == 0 || includeMap [fieldName ]) && ! excludeMap [fieldName ] {
@@ -96,7 +97,7 @@ func GetStructFields[T any](input T) ([]string, error) {
9697 fields := make ([]string , 0 , val .NumField ())
9798 typeOfStruct := val .Type ()
9899 for i := 0 ; i < val .NumField (); i ++ {
99- fields = append (fields , typeOfStruct .Field (i ).Name )
100+ fields = append (fields , strings . ToLower ( typeOfStruct .Field (i ).Name ) )
100101 }
101102
102103 return fields , nil
0 commit comments