Skip to content

Missing warning for string(x) #1318

Closed
@sepetrov

Description

@sepetrov

Thank you for creating the issue!

  • 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).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.30.0 built from 45b90f6 on 2020-08-03T03:10:34Z
Go environment
$ go version && go env
go version go1.15 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build085327369=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint cache clean
$ cat main.go
package main

import "fmt"

func main() {
	var i int
	i = 1234
	fmt.Println(string(i))
}
$ golangci-lint run -v --disable-all -E govet main.go
level=info msg="[config_reader] Config search paths: [./ /app /]"
level=info msg="[lintersdb] Active 1 linters: [govet]"
level=info msg="[loader] Go packages loading at mode 575 (compiled_files|deps|files|imports|exports_file|name|types_sizes) took 203.433221ms"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 2.686936ms"
level=info msg="[linters context/goanalysis] analyzers took 188.290158ms with top 10 stages: inspect: 97.469027ms, ctrlflow: 52.24578ms, printf: 38.049408ms, unreachable: 208.676µs, unsafeptr: 174.519µs, unusedresult: 20.905µs, copylocks: 19.554µs, asmdecl: 14.537µs, assign: 13.705µs, unmarshal: 11.897µs"
level=info msg="[runner] processing took 4.201µs with stages: max_same_issues: 656ns, skip_dirs: 454ns, uniq_by_line: 438ns, nolint: 415ns, cgo: 264ns, max_from_linter: 258ns, source_code: 230ns, path_prettifier: 192ns, skip_files: 188ns, filename_unadjuster: 180ns, exclude: 116ns, exclude-rules: 116ns, autogenerated_exclude: 115ns, identifier_marker: 107ns, path_shortener: 106ns, max_per_file_from_linter: 106ns, diff: 106ns, sort_results: 62ns, path_prefixer: 46ns, severity-rules: 46ns"
level=info msg="[runner] linters took 1.618081038s with stages: govet: 1.618033871s"
level=info msg="File cache stats: 0 entries of total size 0B"
level=info msg="Memory: 20 samples, avg is 113.5MB, max is 137.0MB"
level=info msg="Execution took 1.840217417s"

Go 1.15 introduces a change in go vet:

The vet tool now warns about conversions of the form string(x) where x has an integer type other than rune or byte.

Source: https://golang.org/doc/go1.15#vet

Current version of golangci-lint, downloaded from the releases (or installed using the recommended install.sh script) does not warn about this conversion, because it is compiled using Go 1.14, where go vet still does not warn about such usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions