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
10 changes: 9 additions & 1 deletion mockgen/mockgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,15 @@ func (o identifierAllocator) allocateIdentifier(want string) string {

// Output returns the generator's output, formatted in the standard Go style.
func (g *generator) Output() []byte {
src, err := toolsimports.Process(g.destination, g.buf.Bytes(), nil)
// FormatOnly keeps formatting hermetic: mockgen already emits a complete,
// self-consistent import set, so goimports' add/remove pass (which shells
// out to `go` and breaks in Buck/Bazel) is unnecessary.
src, err := toolsimports.Process(g.destination, g.buf.Bytes(), &toolsimports.Options{
Comments: true,
TabIndent: true,
TabWidth: 8,
FormatOnly: true,
})
if err != nil {
log.Fatalf("Failed to format generated source code: %s\n%s", err, g.buf.String())
}
Expand Down