Questions tagged [golangci-lint]

32 questions
1
vote
1 answer

golangci-lint complains on SQL rows not closed, despite it is closed from a goroutine

I am using golangci-lint as part of my CI/CD. It is complaining on SQL rows not being closed, despite it is being closed from a goroutine: .... rows, err := ... ... go funcThatDoesSomethingWithRows(rows) } ... func…
Gilo
  • 640
  • 3
  • 23
1
vote
1 answer

Deletion of metrics not working kubernetes operator controller

I have been working on my operator where I have some of the custom metric setting the values and that works fine (registration and displaying the metric value). The problem is that metric deletion isn't happening. I tried to declare a separate…
vgdub
  • 347
  • 5
  • 15
1
vote
0 answers

golangci-lint: exec: "git": executable file not found in $PATH

I'm trying to integrate golangci-lint on my project. I use golangci-lint v1.49.0 that I install from snap. I've added ci config on my project but when I try to run it, it throws a very bizarre error. $ golangci-lint run -v INFO [config_reader] Used…
new line
  • 183
  • 2
  • 9
1
vote
1 answer

/../usr/local/go/src/runtime/cgo/cgo.go:34:8: could not import C (cgo preprocessing failed) (typecheck)

Note: current version of Go - 1.17.13 current version of golangci-lint - 1.45.2 I am getting the same error `could not import C (cgo preprocessing failed) (typecheck) no matter which version of golangci-lint I use while I am running…
Komron
  • 19
  • 4
0
votes
1 answer

I can't import local packages in my go project

folder structure: - myproject - resolver - resolver.go - main.go go mod init github.com/kaleabbyh/foodrecipie resolver.go: package resolvers import "fmt" func resolverfunc(){ fmt.Println("resolvers are running") } main.go: package…
kaleab
  • 1
0
votes
0 answers

Getting the error "can't load fmt" - golangci-lint

I installed golangci-lint using the link # binary will be $(go env GOPATH)/bin/golangci-lint curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2 golangci/golangci-lint…
prajeesh
  • 2,202
  • 6
  • 34
  • 59
0
votes
0 answers

VS Code doesn't detect unhandled errors written in GO

VSCode doesn't show a warning on unhandled error. I've got this line of code: defer resp.Body.Close() which is market as unhandled error in GOLAND IDE but in VSCode I don't get similar nice warning as in GOLAND. I've got golangci-lint as my linter,…
Sonny49
  • 425
  • 3
  • 18
0
votes
0 answers

Dynamic vscode settings for linting config?

At work, we have a shared golangci configuration that lives in a github repo, github.com/github/go-linter. I'm trying to figure out how best to share that configuration across many go repos. I've heard that other languages use their package…
Nate Finch
  • 253
  • 3
  • 13
0
votes
2 answers

How to detect error values that are never used

I'm looking for a way to to find occurrences of this error "handling" that doesn't do anything with the first error: example: func handler() { var myErr error myErr = doSomething() //Warn me about this please myErr = doSomethingElse() …
Paul
  • 1,483
  • 14
  • 32
0
votes
0 answers

Golang list indirect dependencies for a dependency in go.mod file

Is there a way we can list down the indirect dependencies of a dependency in go lang go.mod file. For example in go.mod: require ( github.com/blang/semver/v4 v4.0.0 github.com/fatih/structtag v1.1.0 github.com/go-logr/logr v1.2.3 …
Uday Kumar
  • 19
  • 3
0
votes
1 answer

Is there a script to fix opentelemetry lint errors?

When running the make golint target in opentelemetry-collector-contrib, sometimes a lint error will appear. It seems like the kind of lint-check which could be easily fixed as well, but make gofmt will not fix such. Is there a way to use one of the…
Subject17
  • 26
  • 3
0
votes
0 answers

golangci-lint error go imports error computing diff

I´m trying to use golangci-lint with vscode, however when i run it, the following error occurs level=warning msg="[runner] Can't run linter goanalysis_metalinter: goimports: error computing diff: exec: "diff": executable file not found in…
David Meléndez
  • 389
  • 5
  • 15
0
votes
1 answer

GoLang Level3 embedded struct initialisation

I am new to Golang development. I was trying to initialize a struct which has a level 3 embedded struct. I can create till 2 levels, but when I try with level 3, it gives me this compile time error. missing type in composite literal Here is the…
Kamal Kant
  • 1,031
  • 1
  • 12
  • 22
0
votes
1 answer

Variable is being used but Golang lint complaining that the variable is not being used

Below is the code snippet where i have declared a for loop and getting index and box from the array of boxes. I am using the same index below in the if else block, but the golangci-lint is complaining about the variable index unused func…
Anshul Sharma
  • 1,018
  • 3
  • 17
  • 39
-1
votes
1 answer

Where can I find the documentation for SyscallN, since syscall.Syscall6 has been deprecated as of Go 1.18?

When I run golangci-lint on my Go code after changing the go value in my go.mod from go 1.16 to go 1.20, I now get this linter warning: windows.go:210:16: SA1019: syscall.Syscall6 has been deprecated since Go 1.18: Use SyscallN instead.…
Shane Bishop
  • 3,905
  • 4
  • 17
  • 47