File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -68,8 +68,6 @@ func (a *analyzer) run(pass *analysis.Pass) (any, error) {
68
68
}
69
69
70
70
func (a * analyzer ) checkField (pass * analysis.Pass , field * ast.Field ) {
71
- stringToStringMapType := types .NewMap (types .Typ [types .String ], types .Typ [types .String ])
72
-
73
71
underlyingType := pass .TypesInfo .TypeOf (field .Type ).Underlying ()
74
72
75
73
if ptr , ok := underlyingType .(* types.Pointer ); ok {
@@ -87,7 +85,8 @@ func (a *analyzer) checkField(pass *analysis.Pass, field *ast.Field) {
87
85
}
88
86
89
87
if a .policy == config .NoMapsAllowStringToStringMaps {
90
- if types .Identical (m , stringToStringMapType ) {
88
+ if types .AssignableTo (m .Elem ().Underlying (), types .Typ [types .String ]) &&
89
+ types .AssignableTo (m .Key ().Underlying (), types .Typ [types .String ]) {
91
90
return
92
91
}
93
92
Original file line number Diff line number Diff line change @@ -64,3 +64,11 @@ type Component struct {
64
64
Key string `json:"key"`
65
65
Value int32 `json:"value"`
66
66
}
67
+
68
+ type StringBasedType string
69
+
70
+ type MapWithStringBasedTypes struct {
71
+ MapWithStringBasedElement map [string ]StringBasedType `json:"stringBasedMapElem,omitempty"`
72
+ MapWithStringBasedKey map [StringBasedType ]string `json:"stringBasedMapKey,omitempty"`
73
+ MapWithStringBasedKeyAndElem map [StringBasedType ]StringBasedType `json:"stringBasedMapKey,omitempty"`
74
+ }
You can’t perform that action at this time.
0 commit comments