Closed
Description
The error message for goimports
is currently insufficient when run with a local-prefixes
. Suppose we have the following:
main.go:
package main
import (
"fmt"
"github.com/ian-howell/foo/pkg"
"github.com/spf13/cobra"
)
func main() {
fmt.Println(pkg.Foo())
_ = cobra.Command{}
}
.golangci.yaml:
linters-settings:
goimports:
local-prefixes: github.com/ian-howell/foo
linters:
disable-all: true
enable:
- goimports
Running golangci-lint run -c .golangci.yaml
produces the following output:
main.go:6: File is not `goimports`-ed (goimports)
"github.com/ian-howell/foo/pkg"
This message is confusing, because running goimports
on the file doesn't seem to find any issues:
$ diff <(goimports main.go) main.go
$ # no output
Of course, running goimports
with the -local
flag does provide output, but golangci-lint
does not indicate that the flag is needed:
$ diff <(goimports -local github.com/ian-howell/foo main.go) main.go
6,7d5
< "github.com/spf13/cobra"
<
8a7
> "github.com/spf13/cobra"