23 ms·
I like that Go don't allows unused import and variables. If you're working with inexperienced programmers (and some experienced but bad programmers), you shoul
by ahacker15 9y ago
I like that Go don't allows unused import and variables.
If you're working with inexperienced programmers (and some experienced but bad programmers), you should be certain that they WILL let that code garbage there if the compiler allow it.
- johansch 9y agoFunnily enough: I've never found that to be a big problem with other languages in practice. Actually, on a scale of problems in other people's code I'd probably put this very far down the list.
- nuggien 9y agoHave you worked with code where unused variables actually have a side effect?
- Orangeair 9y agoThat's the kind of thing that should be detected by a linter and stop code submission though, not necessarily stop it from even compiling. What if you just want to comment something out quickly? I don't program in Go, but it seems like it would be annoying to have to repeatedly add and remove the main dependencies while I was iterating on something.
- johansch 9y agoIt is absurdly annoying. It's the one thing that put me off golang development, despite all of its nice aspects relating to concurrency. Having custom functionality in editors to work around this apparently dogmatic design decision in the core language.. is also just absurd.
- infogulch 9y agoThis problem is fixed by using the "goimports" tool that will automatically add and remove imports as they're used on save. Pretty much every editor supports it. With goimports and gofmt that formats code, I no longer have to think about formatting and imports at all until I git diff, the whole problem vanishes.