-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/cmd/goimports: Unexpected goimports behaviour depending on prior imports #29180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Possibly related to #23001 |
This is probably related to my recent changes. I'll take a look tomorrow. |
Adding a few more details:
The reference to computeBeta doesn't build, but after running goimports a second time it does result in compilable code. The behavior appears to have changed as of https://go.googlesource.com/tools/+/ee45598d2ff288037f53f9e13ae0b1a6e2165ad5 |
This is a variant of a bug I failed to fix correctly in https://golang.org/cl/153440. CL shortly. |
Change https://golang.org/cl/153859 mentions this issue: |
For completeness, I wanted to confirm that this is working again. Thanks for the quick turnaround! |
Quite welcome, sorry for the glitch. |
What version of Go are you using (
go version
)?go version go1.11 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?darwin (MacOs), amd64
What did you do?
I work on a code generator that generates a Terraform provider for Google Cloud Platform; we generate code without imports and use
goimports
to add them.I updated my local copy of
goimports
today, and ran into some very unexpected changes. There was a large diff, but most importantlygoimports
isn't generating correct imports for at least 1 file anymore.These examples aren't runnable; they're variants of this file, the correct output: https://github.com/terraform-providers/terraform-provider-google/blob/2.0.0/google/resource_compute_subnetwork.go
Given this file: https://play.golang.org/p/Ku1KKO3urCd
when I run
goimports -v -w google/resource_compute_subnetwork.go
What did you expect to see?
I expect to see https://github.com/terraform-providers/terraform-provider-google/blob/2.0.0/google/resource_compute_subnetwork.go
If I run goimports in a separate directory with no other files, I see the correct import path. When I run it on an unformatted copy of the file in the provider repo, I get an incorrect output with the bad import path.
What did you see instead?
Full file: https://play.golang.org/p/wKgEyMWdZto
The text was updated successfully, but these errors were encountered: