3 ms·
This is the one thing above all else which has kept me off Go. Tentatively comment out a line or two and the whole compilation process may come crashing down be
by interfixus 6y ago
This is the one thing above all else which has kept me off Go. Tentatively comment out a line or two and the whole compilation process may come crashing down because now you have a declared but unused variable, and mere warnings apparently aren't Gestapo enough in this particular universe. You then find and comment out the offending declaration, only for the compilation to die in flames again because now you reference a never declared variable. It gets tiresome after a while.
- OskarS 6y agoAre unused variables really compiler errors in Go? That does seem very harsh, and very counter productive while developing. -Werror is all well and good, but while I’m in the middle of writing the code, it’s a bit much.
- interfixus 6y agoThey were, last time I looked. Which was admittedly a while ago.
- Gibbon1 6y agoEven worse if you include something that isn't used, that's also a fatal error.
- strken 6y agoThe theory is that given enough code, any antipattern that compiles will make its way into real use, and therefore the only way to make people stop using an antipattern is to refuse to compile it. Go trades inconvenience in the short term for removing an entire class of bugs and raising the readability floor of bad code.
- pharke 6y agoThat's an insane approach, eslint solves this just fine and is fully configurable for almost any style preference.
- strken 6y agoAll Go code everywhere never has unused variables, never has unused imports, and is formatted similarly. But, when you're debugging a function, you can't leave unused variables or imports lying around. It's a tradeoff. I don't think either side of the tradeoff is insane.
- cbm-vic-20 6y agoSounds like a good argument for a --relax-im-just-trying-something flag for the go compiler, and taint the resulting code with it so if anyone else tries to use the code without the same flag, then the compiler/linker will complain.
- SureshG 6y agoYou can do underscore import and local variable to workaround this limitation and I have seen that in the code.
- francislavoie 6y agoGolang is impossible to use without an IDE like VSCode. Tried it with Sublime Text without a language server and it was a nightmare like you described. Less problematic with VSCode cause it'll add/remove imports automatically on save and have big red underlining for anything that will cause it to not compile.