Skip to content

Goheader linter with only-new-issues false positives #2470

Open
@kke

Description

@kke

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

Trying to enforce changing the boilerplate copyright year only for changed files in PRs using the github action.

When using the action with only-new-issues: true, the diff very rarely touches the header, mostly only when new files are added, allowing the action to pass without changing the year in the copyright, making the linter ineffective.

If using only-new-issues: false, every file is reported failing the header check even if they weren't touched.

Another problem is build directives (// +build !windows), gofmt moves them to top before the boilerplate, goheader fails for each of these because the header doesn't start from the top, so those files need to be excluded.

Version of golangci-lint

golangci-lint has version v1.43.0 built from (unknown, mod sum: "h1:SLwZFEmDgopqZpfP495zCtV9REUf551JJlJ51Ql7NZA=") on (unknown)

Configuration file

linters-settings:
  goheader:
    template-path: .go-header.txt

Go environment

go version go1.17.5 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/kimmo/Library/Caches/go-build"
GOENV="/Users/kimmo/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kimmo/Projects/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/kimmo/Projects/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.17.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.17.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/kimmo/Projects/go/src/github.com/k0sproject/k0s/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/t5/k06n6kss3qz1z5sf0y8pqsw40000gn/T/go-build4190391337=/tmp/go-build -gno-record-gcc-switches -fno-common"

Verbose output of running

...

Code example or link to a public repository

...

Metadata

Metadata

Labels

bugSomething isn't workingdependenciesRelates to an upstream dependency

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions