3 ms·
The "write out your imports" ship sailed with modules. Nobody wants to write out "code.internal.corporate.domain/bureaucratic/hierarchy/of/orgs/foo" when they'r
by kbolino 2y ago
The "write out your imports" ship sailed with modules. Nobody wants to write out "code.internal.corporate.domain/bureaucratic/hierarchy/of/orgs/foo" when they're looking for "foo". Even GitHub-hosted modules have fairly long names.
The tools need to get better though. I'd rather they fall back to asking me than guessing when the import is ambiguous. I also think they should only ever autoimport from the stdlib or what's directly referenced in go.mod.
- SamWhited 2y agoI mean, copy/paste is a thing, I'm not suggesting you have to always type out every single character. Just know what's being imported.
- kbolino 2y agoI don't see a functional difference between copy-paste and autoimport. They have more or less the same risks. Imports should rarely be manually managed directly in source. Doing that is the epitome of tedium and most imports are just boilerplate, so your eyes will glaze over and you'll miss the finer points unless a specific file warrants deeper scrutiny. That doesn't mean imports should never be reviewed, and again, I think the tools need a lot of improvement in this regard.
- tedunangst 2y agoI've never copy and pasted crypto/rand and gotten math/rand.
- kbolino 2y agoYeah that's a legit gripe but I wasn't really talking about the standard library which uses nice short import paths.