Skip to content

I get "File is not goimports-ed" for a valid import #1462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
avishaik opened this issue Oct 20, 2020 · 6 comments
Closed

I get "File is not goimports-ed" for a valid import #1462

avishaik opened this issue Oct 20, 2020 · 6 comments
Labels
feedback required Requires additional feedback stale No recent correspondence or work activity

Comments

@avishaik
Copy link

avishaik commented Oct 20, 2020

Hi,

I get a lint error:

File is not `goimports`-ed (goimports)
        "github.com/x-cray/logrus-prefixed-formatter"

For the following import:

import (
	"os"

	"github.com/sirupsen/logrus"
	"github.com/x-cray/logrus-prefixed-formatter"
)

The above result is after goimport for the file, and still the linter give this error.

@boring-cyborg
Copy link

boring-cyborg bot commented Oct 20, 2020

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@bombsimon
Copy link
Member

bombsimon commented Oct 21, 2020

I’ve seen this before and we need to investigate. In the meantime, you can fix this with the fixer:

golangci-lint run --fix

@SVilgelm
Copy link
Member

here is my file:

package main

import (
        "os"

        "github.com/sirupsen/logrus"
        prefixed "github.com/x-cray/logrus-prefixed-formatter"
)

var log = logrus.New()

func init() {
        log.Formatter = new(prefixed.TextFormatter)
        log.Level = logrus.DebugLevel
}

func main() {
        log.WithFields(logrus.Fields{
                "prefix": "main",
                "animal": "walrus",
                "number": 8,
        }).Debug("Started observing beach")

        log.WithFields(logrus.Fields{
                "prefix":      "sensor",
                "temperature": -4,
        }).Info("Temperature changes")
        os.Exit(1)
}

And here is the golangci-lint output:

21-01-10 19:10 % golangci-lint run -v --no-config --disable-all -E goimports main.go
INFO [lintersdb] Active 1 linters: [goimports]    
INFO [loader] Go packages loading at mode 7 (compiled_files|files|name) took 360.298488ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 218.741µs 
INFO [linters context/goanalysis] analyzers took 0s with no stages 
INFO [runner] processing took 5.759µs with stages: max_same_issues: 2.089µs, nolint: 1.494µs, skip_dirs: 262ns, max_from_linter: 223ns, path_shortener: 148ns, identifier_marker: 141ns, cgo: 139ns, diff: 136ns, source_code: 135ns, path_prettifier: 135ns, skip_files: 130ns, uniq_by_line: 128ns, autogenerated_exclude: 125ns, filename_unadjuster: 119ns, max_per_file_from_linter: 67ns, exclude: 59ns, sort_results: 59ns, severity-rules: 57ns, exclude-rules: 57ns, path_prefixer: 56ns 
INFO [runner] linters took 624.048µs with stages: goimports: 567.261µs 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 5 samples, avg is 73.3MB, max is 73.3MB 
INFO Execution took 376.854694ms                  

@SVilgelm
Copy link
Member

@avishaik Do you still have this issue? If no, then let's close

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No recent correspondence or work activity label Apr 16, 2022
@stale stale bot closed this as completed Jul 10, 2022
@Akkarine
Copy link

For poor souls like me getting this error (right on "package" instruction) in JetBrains IDE with Go linter plugin on Windows for completely valid imports, check line separators of file. I believe diff tool needed for goimports linter have problems with CRLF. After converting to LF all was fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback required Requires additional feedback stale No recent correspondence or work activity
Projects
None yet
Development

No branches or pull requests

5 participants