Skip to content

x/tools/cmd/goimports: -srcdir rewrites paths in parser errors #14864

@dominikh

Description

@dominikh

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions