Go version
go version go1.25.1 linux/amd64
Output of go env
in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v4'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/u/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/u/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3885639297=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/u/hb/seller-experience/vms/go.mod'
GOMODCACHE='/home/u/go/pkg/mod'
GONOPROXY='gitlab.com/HnBI/*'
GONOSUMDB='gitlab.com/HnBI/*'
GOOS='linux'
GOPATH='/home/u/go'
GOPRIVATE='gitlab.com/HnBI/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/u/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.1'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
I tried to run a go vet linter on code line string(int32(1))
.
What did you see happen?
go vet does not report an error: https://go.dev/play/p/ThuI0i8PQ1P
𖢺
Program exited.
What did you expect to see?
I expect vet to emit the same error as string(int(1))
does: https://go.dev/play/p/YeZ1nhgSuK8
# [play]
./prog.go:8:14: conversion from int to string yields a string of one rune, not a string of digits
Go vet failed.
𖢺
Program exited.
Comment From: gabyhelp
Related Issues
- cmd/vet: don't complain about int to string conversion (at least in some cases) #46597 (closed)
- cmd/vet: cannot convert s (variable of type parameter T constrained by ~string) to string #49186 (closed)
- cmd/vet: false positives and wrong types across files, needs automatic recursive checking #20514 (closed)
- cmd/vet: doesn't handle formatting strings in variables #44063
- cmd/vet: go vet panics on type assertion #12114 (closed)
- cmd/vet: exit code should be 1 in case a problem is reported, not 2 #45515
- cmd/vet: false positive printf-like function detection for github.com/leonelquinteros/gotext #57288 (closed)
- cmd/vet: Formatting string check cannot see through type assertions or varargs #70814 (closed)
- cmd/vet: improve error message for string(int) warning #39151 (closed)
- go vet incorrectly recognizes format verb in string #38131 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: ianlancetaylor
This is intentional. The predeclared type rune is an alias for int32, and plenty of code correctly converts a single rune value to a string.