Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mockgen/package_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (p *packageModeParser) loadPackage(packageName string) (*packages.Package,
}

cfg := &packages.Config{
Mode: packages.NeedDeps | packages.NeedImports | packages.NeedTypes | packages.NeedTypesInfo | packages.NeedEmbedFiles | packages.LoadSyntax,
Mode: packages.LoadSyntax,
Copy link
Author

@johanneswuerbach johanneswuerbach Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was simplified according to https://pkg.go.dev/golang.org/x/tools/go/packages#pkg-constants, which states that LoadSyntax is essentially all other options except NeedDeps and NeedEmbedFiles.

Not sure why NeedEmbedFiles was used here, but NeedDeps is the biggest performance hit and the tests are still passing with it being removed and our mocks are generated just fine.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2025/03/18 13:14:21 internal error: package "encoding/json" without types was imported from "<package>"

We've just run into the (in our case) 2x performance degradation (15m -> 30m), unfortunately this change (specifically the removal of NeedDeps) doesn't seem to work as we're unable to find types for the third party packages that we're using.

BuildFlags: buildFlagsSet,
}
pkgs, err := packages.Load(cfg, packageName)
Expand Down