-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
golang/tools
#299Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.16 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What did you do?
See https://play.golang.org/p/yv78HSm0AX6 for a full example, and https://play.golang.org/p/GmUF-tayOgI for an interactive example (hit "Format" with imports enabled).
What did you expect to see?
package main
import (
"errors"
"github.com/pkg/errors"
"github.com/juju/errors"
)
func main() {
}This file has three imported errors packages, none of them are referenced outside of the import block, so they should all be removed, resulting in this output:
package main
func main() {
}What did you see instead?
Only one errors package is removed per iteration - seemingly always the last one to appear. Because we have three imported packages, we need to run imports.Process three times to prune all the unused imports.
Iteration 1:
package main
import (
"errors"
"github.com/pkg/errors"
)
func main() {
}Iteration 2:
package main
import (
"errors"
)
func main() {
}Iteration 3:
package main
func main() {
}Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.