File tree 2 files changed +18
-3
lines changed
2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -47,15 +47,25 @@ func (l *lintNestedStructs) Visit(n ast.Node) ast.Visitor {
47
47
}
48
48
return nil
49
49
case * ast.Field :
50
- if _ , ok := v .Type .(* ast.StructType ); ok {
50
+ filter := func (n ast.Node ) bool {
51
+ switch n .(type ) {
52
+ case * ast.StructType :
53
+ return true
54
+ default :
55
+ return false
56
+ }
57
+ }
58
+ structs := pick (v , filter , nil )
59
+ for _ , s := range structs {
51
60
l .onFailure (lint.Failure {
52
61
Failure : "no nested structs are allowed" ,
53
62
Category : "style" ,
54
- Node : v ,
63
+ Node : s ,
55
64
Confidence : 1 ,
56
65
})
57
- break
58
66
}
67
+ return nil // no need to visit (again) the field
59
68
}
69
+
60
70
return l
61
71
}
Original file line number Diff line number Diff line change @@ -30,3 +30,8 @@ func fred() interface{} {
30
30
31
31
return s
32
32
}
33
+
34
+ // issue 664
35
+ type Bad struct {
36
+ Field []struct {} // MATCH /no nested structs are allowed/
37
+ }
You can’t perform that action at this time.
0 commit comments