@@ -124,10 +124,10 @@ type result struct {
124124// workingDir is the directory to use to run go commands.
125125//
126126// 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 ) {
128128 pages := map [string ]* page {}
129129
130- pkgInfos , err := loadPackages (glob , workingDir )
130+ pkgInfos , err := loadPackages (glob , workingDir , filter )
131131 if err != nil {
132132 return nil , err
133133 }
@@ -599,7 +599,7 @@ type pkgInfo struct {
599599 importRenames map [string ]string
600600}
601601
602- func loadPackages (glob , workingDir string ) ([]pkgInfo , error ) {
602+ func loadPackages (glob , workingDir string , filter [] string ) ([]pkgInfo , error ) {
603603 config := & packages.Config {
604604 Mode : packages .NeedName | packages .NeedSyntax | packages .NeedTypes | packages .NeedTypesInfo | packages .NeedModule | packages .NeedImports | packages .NeedDeps ,
605605 Tests : true ,
@@ -626,6 +626,11 @@ func loadPackages(glob, workingDir string) ([]pkgInfo, error) {
626626 idToPkg := map [string ]* packages.Package {}
627627 pkgNames := []string {}
628628 for _ , pkg := range allPkgs {
629+ // Ignore filtered packages.
630+ if hasPrefix (pkg .PkgPath , filter ) {
631+ continue
632+ }
633+
629634 id := pkg .ID
630635 // See https://pkg.go.dev/golang.org/x/tools/go/packages#Config.
631636 // The uncompiled test package shows up as "foo_test [foo.test]".
0 commit comments