Hacker News new | ask | show | jobs
by demizer 896 days ago
All these plan9 scientists love their own brand. I started using Go in 2012, but after they killed deps.dev I gave it up. Some years later when I wanted to get work done at work I tried to introduce it on my team and another engineer spent a good amount of time looking into the language and listed all the reasons why it sucked, and he was right. The main takeaway was, yeah it's simple, but it does silly things that makes it a pain to use (error handling and unused imports) to name a few. I personally like the error handling but hated the type system.
1 comments

Just run goimports on save then there would be no issue with unused imports. I would take go's error handling over try/catch any day of the week.
You then have to reimport. Every time when you comment out code.

I guess the compiler authors don't comment out code?

And it's intentionally not optional on the compiler.

So you have to modify the source and compile your own compiler to disable it. It's ridiculously sadistic to their users.

If you use goimports (which also runs gofmt) after commenting out code, you just have to save your file and it will remove any unused imports. There is no reason to go to the extreme extent of compiling your own modified version of go just for this. The tooling is already there.
The OP mentions that the reimport is the problem (in response to your tooling suggestion). If you comment out code while testing the imports are auto-removed. When you uncomment you need add the correct imports again.
goimports re-adds them when you uncomment the code. Unless it is ambiguous on which lib to import which doesn't happen very often.
I might not have used `goimports` before. I read now that it also auto-imports when you uncomment. That's neat, but it could auto-import the wrong thing, and I'm not sure how it would handle conflicts. It still seems worse than just ignoring my unused imports. Unused imports should be more of a linting thing? If the compiler knows its unused, I don't see why it can't just ignore it.
Yes, it can import the wrong thing (or version) but it doesn't happen that often in my experience. If you use the libraries in other files it can go off of what is already in your go.mod file.
Is it possible to comment out the imports?