Problems with goimports I has as programmer, that usually does not uses go
There was a old problem, when one o my co-workers did not know, why the go linter control was failing at work. So we went and tried to figure out, what was wrong.
The first thing was realizing, that using the goimports on the whole project takes too long, so this was scraped. Helpfully, the goimports can check just one file with
But this only printed in the terminal the formatted file. So my first impressions was, I just need to pipe it back in the same file. Not a good idea, because for some reason, git recognized this as the file completly changed. Not a good experience for anybody, that would review a pull request.
So the next thing I find out was the
The next thing was, that we were using the different format than the default. I have questions why, but not my problem. So we were be able to format it correctly by adding also the flag
Which I then saw, that the error message was tiring to be helpful, I just did not see it the first time. This was the error message:
File is notfile:line: goimports
-ed with -local github.com/org/project (goimports). Well, at least I will know the next time.
There was still a problem of the program saving it in the different format then we wanted. But as long as the file was formatted in the terminal afterwards, we could push that version and the linter control was happy.