File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -97,14 +97,25 @@ type runner struct {
97
97
disableFact bool
98
98
}
99
99
100
+ func getPkgRoot (pkg string ) string {
101
+ arr := strings .Split (pkg , "/" )
102
+ if len (arr ) < 3 {
103
+ return arr [0 ]
104
+ }
105
+ if strings .IndexByte (arr [0 ], '.' ) == - 1 {
106
+ return arr [0 ]
107
+ }
108
+ return strings .Join (arr [:3 ], "/" )
109
+ }
110
+
100
111
func NewRun (pkgs []* packages.Package , disableFact bool ) func (pass * analysis.Pass ) (interface {}, error ) {
101
112
m := make (map [string ]bool )
102
113
for _ , pkg := range pkgs {
103
- m [strings . Split (pkg .PkgPath , "/" )[ 0 ] ] = true
114
+ m [getPkgRoot (pkg .PkgPath ) ] = true
104
115
}
105
116
return func (pass * analysis.Pass ) (interface {}, error ) {
106
117
// skip different repo
107
- if len (m ) > 0 && ! m [strings . Split (pass .Pkg .Path (), "/" )[ 0 ] ] {
118
+ if len (m ) > 0 && ! m [getPkgRoot (pass .Pkg .Path ()) ] {
108
119
return nil , nil
109
120
}
110
121
if len (m ) == 0 && pkgprefix != "" && ! strings .HasPrefix (pass .Pkg .Path (), pkgprefix ) {
You can’t perform that action at this time.
0 commit comments