File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -61,14 +61,14 @@ func redact(v reflect.Value, tag string) {
6161 }
6262
6363 case reflect .String :
64- if v .CanSet () {
65- v .SetString (transformString (v .String (), tag ))
66- }
64+ v .SetString (transformString (v .String (), tag ))
6765
6866 case reflect .Struct :
6967 for i := 0 ; i < v .NumField (); i ++ {
70- tag , _ := v .Type ().Field (i ).Tag .Lookup (tagName )
71- redact (v .Field (i ), tag )
68+ if v .Field (i ).CanSet () {
69+ tag , _ := v .Type ().Field (i ).Tag .Lookup (tagName )
70+ redact (v .Field (i ), tag )
71+ }
7272 }
7373 }
7474}
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ type TestStruct struct {
2525 SecretPtr * string
2626 NonSecret string `redact:"nonsecret"`
2727 unexported string
28+ unexportedMap map [string ]string
2829}
2930
3031type TestStructList struct {
@@ -57,6 +58,7 @@ func TestStringTestStruct(t *testing.T) {
5758 SecretStringType : secretVal ,
5859 SecretPtr : & secretPtrVal ,
5960 unexported : nonSecretVal ,
61+ unexportedMap : map [string ]string {"" : "" },
6062 }
6163
6264 err := redact .Redact (tStruct )
You can’t perform that action at this time.
0 commit comments