Questions tagged [golint]

Golint is a linter for Go source code.

Golint makes code style recommendations.

Check this Github repo for more details

NOTE: Golint is deprecated and frozen. There are some other tools for this purpose such as go vet.

38 questions
88
votes
4 answers

Fix "should not use basic type string as key in context.WithValue" golint

I am passing an uuid in using the Context and WithValue to subsequent functions that handle this *http.request. This uuid is was passed in the authorization header to a REST call to identify a person. The authorization token is verified and needs to…
snorberhuis
  • 3,108
  • 2
  • 22
  • 29
57
votes
4 answers

"Exported type should have comment or be unexported" golang VS Code

I tried this code in Go: type Agent struct { name string // Not exported categoryId int // Not exported } And VS Code reports the following problem: exported type Agent should have comment or be unexported The warning is kind of…
channa ly
  • 9,479
  • 14
  • 53
  • 86
52
votes
14 answers

Go linter in VS code not working for packages across multiple files?

I have installed the Go extension (version 0.11.4) in Visual Studio Code on MacOS: However, I find that the linter does not 'pick up' functions defined in the same package, but in different files. For example, if I create in the same directory a…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
11
votes
2 answers

Meaning of "File is not `gci`-ed with --skip-generated -s standard,default (gci)"

I get this error message: main.go:24: File is not `gci`-ed with --skip-generated -s standard,default (gci) import ( What does this mean? Background: I am new to Go, and the linting was not set up by me. I confess that I don't know the actual linter…
guettli
  • 25,042
  • 81
  • 346
  • 663
6
votes
1 answer

golangci-lint gives unseen errors after reinstalling

I upgraded the version of go to go1.18.3, following the instruction on https://go.dev/doc/install: rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.3.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin Then I tried to run a Makefile for my…
instant501
  • 195
  • 1
  • 10
6
votes
3 answers

G110: Potential DoS vulnerability via decompression bomb (gosec)

I'm getting the following golintci message: testdrive/utils.go:92:16: G110: Potential DoS vulnerability via decompression bomb (gosec) if _, err := io.Copy(targetFile, fileReader); err != nil { ^ Read the corresponding CWE and…
gliptak
  • 3,592
  • 2
  • 29
  • 61
5
votes
1 answer

How to use pointers or indexing on a range to resolve rangeValCopy gocritic message

I'm getting the following output when running https://golangci-lint.run/: rangeValCopy: each iteration copies 128 bytes (consider pointers or indexing) (gocritic) for _, v := range products { Here is a cut down version of the code I am…
mikelovelyuk
  • 4,042
  • 9
  • 49
  • 95
4
votes
1 answer

how skip file in golangci-lint?

I try go1.16 import "embed" I get > golangci-lint run ./... > Can't run linter goanalysis_metalinter: bodyclose: failed prerequisites ... could not import embed how skip file/package in golangci-lint?
batazor
  • 852
  • 2
  • 16
  • 36
4
votes
1 answer

GoSublime/GoLint caching Import Packages?

Does SublimeText 3 / GoSublime have some type of caching of Go import packages? If so, how do I clear it on demand? I ask because while writing a custom package that is under Github source control, it works until I refactor a func or struct. Then,…
eduncan911
  • 17,165
  • 13
  • 68
  • 104
3
votes
2 answers

golint support for JetBrains GoLand

I'm using GoLand IDE for developing Go applications. I decided to use this as lots of things worked out of the box and I'm used to JetBrains IDEs (Android Studio, AppCode, IntelliJ) and I feel very effective with the learned keyboard…
Vince Varga
  • 6,101
  • 6
  • 43
  • 60
2
votes
0 answers

Getting undefined typecheck go lint with custom struct that are in different files

This is my main file package datamodels import "time" type Training struct { Id string `param:"id" json:"id,omitempty" firestore:"id"` Image string `json:"image,omitempty" firestore:"image"…
Almog
  • 2,639
  • 6
  • 30
  • 59
2
votes
1 answer

missing cases in switch of type parsing.tokenType on golinter

So I have this code token := NextToken() switch token.Typ { case tokenEOF: return nil case tokenMentionTargetedControl: # do stuff default: return nil } my tokentype is a enum my golinter is throwing this error: missing cases in switch…
Raul Quinzani
  • 493
  • 1
  • 4
  • 16
2
votes
0 answers

Go Lint only check new test diff files (Perforce)

I have a go linter in a .golangci.yml file for my workspace. As of now, I have disabled lints in test files since there are simply too many checks: run: tests: false # rest of run configs ... issues: # all run issues However, I want to…
Muju
  • 21
  • 2
2
votes
1 answer

How to ignore test files(_test.go) using go/analysis?

How to ignore test files(_test.go) using go/analysis? It seems like that go/analysis load test files by default.
zsh.sec
  • 21
  • 2
2
votes
0 answers

On Running golangci-lint it lints the go-1.13 code

Im adding golangci-lint to my makefile and for some strange reason its linting the official go-1.13 source code. This is very confusing and i think it may have something to do with my go envs Here is a snipped of the error…
Robert O'Brien
  • 133
  • 1
  • 11
1
2 3