Skip to content
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

x/lint/golint: looped goroutines should raise a warning #36484

Closed
nektro opened this issue Jan 9, 2020 · 1 comment
Closed

x/lint/golint: looped goroutines should raise a warning #36484

nektro opened this issue Jan 9, 2020 · 1 comment

Comments

@nektro
Copy link

nektro commented Jan 9, 2020

What version of Go are you using (go version)?

$ go version
go version go1.12.7 linux/amd64

Does this issue reproduce with the latest release?

Untested at the time of writing

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/meghan/snap/code/common/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/meghan/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build822957010=/tmp/go-build -gno-record-gcc-switches"

What did you do?

for i := 0; i < count; i++ {
	go func() {
		//
	}()
}

What did you expect to see?

A warning that this is a bad pattern from go-lint.

What did you see instead?

Nothing.

@gopherbot gopherbot added this to the Unreleased milestone Jan 9, 2020
@toothrot
Copy link
Contributor

toothrot commented Jan 9, 2020

There are many reasons to start a goroutine in a loop, such as starting up a pool of workers, or executing requests in parallel. See the example in https://golang.org/pkg/sync/#WaitGroup.

Could you add more details why you believe this deserves a lint warning?

@nektro nektro closed this as completed Jan 10, 2020
@golang golang locked and limited conversation to collaborators Jan 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants