Tuesday, January 14, 2025
HomeGolangIs there linter + autoformat for golang tasks? - Getting Assist

Is there linter + autoformat for golang tasks? – Getting Assist


I attempted to make use of Golangci-lint, however it by default exhibits many alerts from commonplace lib as an alternative of present challenge, undecided if there are current options

Are you not utilizing gofmt? Most main editors will gofmt your code on save.

Assume I’m utilizing it with out realizing. This was for CI use case the place I’ve to alert linting errors earlier than merging. Assume that would work with gofmt, was simply questioning if there have been commonplace options for this.

I don’t know of something I’d think about a “commonplace” answer. Formatting is rarely an issue for my tasks as a result of everyone makes use of VSCode which gofmt’s on save. A lot of the stuff that linting would catch, I catch on code evaluation. I’d see should you can arrange Golangci-lint in such a means that it isn’t supplying you with alerts for the stdlib. That feels like undesirable conduct and I think about you’ll be able to tweak it.

Yeah, it appears to be like one thing like
WARN [linters_context] operating gomoddirectives failed: didn’t get module file: go.mod:3: invalid go model ‘1.22.2’: should match format 1.23: in case you are not utilizing go modules it’s steered to disable this linter
…/…/…/…/choose/homebrew/Cellar/go/1.22.2/libexec/src/errors/be a part of.go:57:16: String not declared by bundle unsafe (typecheck)
return unsafe.String(&b[0], len(b))
^
…/…/…/…/choose/homebrew/Cellar/go/1.22.2/libexec/src/inner/reflectlite/kind.go:198:16: String not declared by bundle unsafe (typecheck)
return unsafe.String(n.knowledge(1+i, “non-empty string”), l)
^
…/…/…/…/choose/homebrew/Cellar/go/1.22.2/libexec/src/inner/reflectlite/kind.go:207:16: String not declared by bundle unsafe (typecheck)
return unsafe.String(n.knowledge(1+i+l+i2, “non-empty string”), l2)
^
…/…/…/…/choose/homebrew/Cellar/go/1.22.2/libexec/src/inner/reflectlite/kind.go:256:11: t.Unusual undefined (kind rtype has no area or technique Unusual, however does have unusual) (typecheck)
return t.Unusual()
^
…/…/…/…/choose/homebrew/Cellar/go/1.22.2/libexec/src/inner/reflectlite/kind.go:260:19: t.Str undefined (kind rtype has no area or technique Str) (typecheck)
s := t.nameOff(t.Str).Identify()
^
…/…/…/…/choose/homebrew/Cellar/go/1.22.2/libexec/src/inner/reflectlite/kind.go:261:7: t.TFlag undefined (kind rtype has no area or technique TFlag) (typecheck)
if t.TFlag&abi.TFlagExtraStar != 0 {
^
…/…/…/…/choose/homebrew/Cellar/go/1.22.2/libexec/src/inner/reflectlite/kind.go:286:7: t.TFlag undefined (kind rtype has no area or technique TFlag) (typecheck)
if t.TFlag&abi.TFlagNamed == 0 {
^

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments