@@ -124,10 +124,10 @@ type result struct {
124
124
// workingDir is the directory to use to run go commands.
125
125
//
126
126
// optionalExtraFiles is a list of paths relative to the module root to include.
127
- func parse (glob string , workingDir string , optionalExtraFiles []string ) (* result , error ) {
127
+ func parse (glob string , workingDir string , optionalExtraFiles []string , filter [] string ) (* result , error ) {
128
128
pages := map [string ]* page {}
129
129
130
- pkgInfos , err := loadPackages (glob , workingDir )
130
+ pkgInfos , err := loadPackages (glob , workingDir , filter )
131
131
if err != nil {
132
132
return nil , err
133
133
}
@@ -599,7 +599,7 @@ type pkgInfo struct {
599
599
importRenames map [string ]string
600
600
}
601
601
602
- func loadPackages (glob , workingDir string ) ([]pkgInfo , error ) {
602
+ func loadPackages (glob , workingDir string , filter [] string ) ([]pkgInfo , error ) {
603
603
config := & packages.Config {
604
604
Mode : packages .NeedName | packages .NeedSyntax | packages .NeedTypes | packages .NeedTypesInfo | packages .NeedModule | packages .NeedImports | packages .NeedDeps ,
605
605
Tests : true ,
@@ -626,6 +626,11 @@ func loadPackages(glob, workingDir string) ([]pkgInfo, error) {
626
626
idToPkg := map [string ]* packages.Package {}
627
627
pkgNames := []string {}
628
628
for _ , pkg := range allPkgs {
629
+ // Ignore filtered packages.
630
+ if hasPrefix (pkg .PkgPath , filter ) {
631
+ continue
632
+ }
633
+
629
634
id := pkg .ID
630
635
// See https://pkg.go.dev/golang.org/x/tools/go/packages#Config.
631
636
// The uncompiled test package shows up as "foo_test [foo.test]".
0 commit comments