-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Closed
Copy link
Milestone
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
Go 1.8
What operating system and processor architecture are you using (go env)?
linux/amd64
What did you do?
This is on the latest version of goimports (golang/tools@8e779ee).
Consider this test program:
package main
import (
"time"
)
func main() {
_ = snappy.Encode
_ = unix.Mmap
_ = time.Parse
}
It's missing two imports. If we run goimports -w fmt.go, we'll get
package main
import (
"time"
"github.com/golang/snappy"
"golang.org/x/sys/unix"
)
func main() {
_ = snappy.Encode
_ = unix.Mmap
_ = time.Parse
}
This is what I expect. However, if we delete the unix import:
package main
import (
"time"
"github.com/golang/snappy"
)
func main() {
_ = snappy.Encode
_ = unix.Mmap
_ = time.Parse
}
and then run goimports again, we get this grouping:
package main
import (
"time"
"golang.org/x/sys/unix"
"github.com/golang/snappy"
)
func main() {
_ = snappy.Encode
_ = unix.Mmap
_ = time.Parse
}
In this second case, I'd expect the file to be the same as the first case instead of introducing a new grouping.
/cc @bradfitz
Reactions are currently unavailable