Closed
Description
- 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/)
Commands print to Stderr instead of StdOut
Trying to fetch the version in a shell script: CI_VERSION=$(golangci-lint version --format short)
I noticed the variable was empty and I could see the version printed in the terminal.
After investigating I found out that golangci-lint
uses Cobra's Println
function:
golangci-lint/pkg/commands/version.go
Lines 35 to 38 in c1d7cfd
According to Cobra, that function prints to Stderr
per default:
https://github.com/spf13/cobra/blob/b55fa79836c63eab81e884e6ec1d7e4ae5c7f9b5/command.go#L1201
Version of golangci-lint
Installed automatically with VS Code$ golangci-lint --version
golangci-lint has version v1.38.0 built from (unknown, mod sum: "h1:hgZsLRzZrjhpp44Ak+fhXNzgrbDF39ETf22a+Jd3fJQ=") on (unknown)
Config file
$ cat .golangci.yml
run:
modules-download-mode: readonly
Go environment
$ go version && go env
go version go1.16.2 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="<redacted>/Library/Caches/go-build"
GOENV="<redacted>/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="<redacted>/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="<redacted>"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.16.2/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.16.2/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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/8c/qd3ywlk1039f53l5m8mnfg1w0000gn/T/go-build3420486587=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
NOT RELEVANT
Code example or link to a public repository
export CI_VERSION=$(golangci-lint version --format short)
echo "current: ${CI_VERSION}"