Skip to content

gochecknoinits using undocumented name init #4697

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
5 tasks done
abemedia opened this issue May 5, 2024 · 1 comment · Fixed by #4698
Closed
5 tasks done

gochecknoinits using undocumented name init #4697

abemedia opened this issue May 5, 2024 · 1 comment · Fixed by #4698
Assignees
Labels
bug Something isn't working

Comments

@abemedia
Copy link
Contributor

abemedia commented May 5, 2024

Welcome

Description of the problem

Since updating to v1.58.0 I'm getting the following errors:

  • directive `//nolint:gochecknoinits` is unused for linter "gochecknoinits" (nolintlint)
  • don't use `init` function (init)

If I change //nolint:gochecknoinits to //nolint:init I get

WARN [runner/nolint] Found unknown linters in //nolint directives: init 

It appears as though the linter was renamed in parts of the application but not all, and most importantly this change isn't documented.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.58.0 built with go1.22.2 from 28b3813 on 2024-05-02T20:58:31Z

Configuration

linters:
  enable-all: true

Go environment

$ go version && go env
go version go1.22.2 darwin/amd64
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/adam/Library/Caches/go-build'
GOENV='/Users/adam/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/adam/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/adam/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/Cellar/go/1.22.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/Cellar/go/1.22.2/libexec/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='***'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/xh/ttknrcjs3tbfv99f83f454d40000gn/T/go-build638368919=/tmp/go-build -gno-record-gcc-switches -fno-common'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here

A minimal reproducible example or link to a public repository

package main

import (
	"fmt"
)

//nolint:gochecknoinits
func init() {
	fmt.Println("init")
}

func main() {
	fmt.Println("main")
}

Validation

  • Yes, I've included all information above (version, config, etc.).
@abemedia abemedia added the bug Something isn't working label May 5, 2024
@ldez ldez self-assigned this May 5, 2024
@ldez
Copy link
Member

ldez commented May 5, 2024

Hello,

I found the problem, I will fix it.

As a temporary workaround, you can remove the nolint directive and use the exclude-rules

issues:
  exclude-rules:
    - path: path/to/a/file.go
      text: "don't use `init` function"

@ldez ldez closed this as completed in #4698 May 5, 2024
chmouel added a commit to chmouel/pipelines-as-code that referenced this issue May 6, 2024
this is a bug introduce in 1.58.0 golangci-lint and should be fixed soon
but we can work around for now like this for now, see:

golangci/golangci-lint#4697

fix some other yamllint error as well along the way.

Signed-off-by: Chmouel Boudjnah <[email protected]>
chmouel added a commit to openshift-pipelines/pipelines-as-code that referenced this issue May 6, 2024
this is a bug introduce in 1.58.0 golangci-lint and should be fixed soon
but we can work around for now like this for now, see:

golangci/golangci-lint#4697

fix some other yamllint error as well along the way.

Signed-off-by: Chmouel Boudjnah <[email protected]>
joshuatcasey added a commit to vmware-tanzu/pinniped that referenced this issue May 8, 2024
jimmidyson added a commit to nutanix-cloud-native/cluster-api-runtime-extensions-nutanix that referenced this issue May 8, 2024
See golangci/golangci-lint#4697 for details
and waiting on golangci/golangci-lint#4698 to be
released before we can revert this fix.
jimmidyson added a commit to nutanix-cloud-native/cluster-api-runtime-extensions-nutanix that referenced this issue May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants