4 ms·
I'm not sure what happened in your case, but it probably wasn't what you describe. We changed goimports in 2016 to prefer crypto/rand over math/rand (https://go
by rsc 2y ago
I'm not sure what happened in your case, but it probably wasn't what you describe. We changed goimports in 2016 to prefer crypto/rand over math/rand (https://go-review.googlesource.com/24847 https://go-review.googlesource.com/24847), and that was before there was VSCode support for Go.
- rsc 2y agoFilippo and I dug into this a bit more, and it is possible that VSCode auto-complete (which also adds imports for the auto-completed things) is the culprit here. Apologies if that's what happened to you. We will look into fixing that. Now that math/rand.Read is marked deprecated, at least if it does get selected, you get a nice strikethrough rendering as well.
- meling 2y agoIt is probably not related, but gopls has a known issue with its heuristic for picking imports: https://github.com/golang/go/issues/61208 https://github.com/golang/go/issues/61208