Running goimports with the -srcdir flag on a file with invalid Go syntax will produce syntax errors with paths in the directory provided by -srcdir, not the actual file. This is arguably confusing, because now the error might refer to a file that doesn't exist.
$ echo "package" > /tmp/foo.go
$ goimports -srcdir /somewhere/else /tmp/foo.go
/somewhere/else/foo.go:1:9: expected 'IDENT', found 'EOF'
I would expect /tmp/foo.go:1:9 in the error output.
/cc @bradfitz