Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
cmd/gofmt: doesn't simplify slices if there is a dot import #15153
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
What operating system and processor architecture are you using (go env)?
What did you do?
What did you expect to see?
What did you see instead?
gofmt has a special check for dot imports and refuses to simplify slices in that case, claiming that it's impossible to know whether len is referring to the built-in function or not. I don't see how that could be true. Even a dot import will only pull in exported identifiers from a package, and no exported identifier can be called "len". Am I missing something here?
@dominikh You're absolutely correct. In fact, even w/o the dot-import we actually can't be certain whether
So in some sense this was always wrong, but in practice, nobody in his/her right mind is going to declare a
I'm not sure how I got to this code - for sure it's pretty old code. Would need to track down the history of that line to figure it out. Let's blame it on lack of coffee. Fix coming shortly.