wire icon indicating copy to clipboard operation
wire copied to clipboard

Anonymous imports get pushed into a separate import declaration

Open reillywatson opened this issue 3 years ago • 0 comments

Describe the bug

If I have an anonymous import in a package that uses Wire, that import gets copied to wire_gen.go, but it gets copied in some separate import declaration instead of being part of the rest of the imports.

To Reproduce

The PkgImport test has an example of this behavior: https://github.com/google/wire/blob/8b20581338ae25def597310313636a508b089c1c/internal/wire/testdata/PkgImport/want/wire_gen.go#L13

import (
	"example.com/bar"
)

import (
	_ "example.com/anon1"
	_ "example.com/anon2"
)

This is legal, but not really idiomatic. In particular goimports doesn't care for it, and it doesn't match any other Go code I've seen in the wild.

Expected behavior

Imports being all part of the same import declaration, like most Go code:

import (
	_ "example.com/anon1"
	_ "example.com/anon2"
	"example.com/bar"
)

Version

0.5.0

Additional context

This is causing issues with the goimports check in our CI.

reillywatson avatar May 10 '22 15:05 reillywatson