Skip to content

x/tools/stringer: stringer: no value for constant (for Go 1.23) #68882

Closed
@olegrok

Description

@olegrok

Go version

go version go1.23.0 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/oleg/.cache/go-build'
GOENV='/home/oleg/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/oleg/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/oleg/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/oleg/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/oleg/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/oleg/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/oleg/Projects/toy-cluster/go.mod'
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1613584254=/tmp/go-build -gno-record-gcc-switches'

What did you do?

After I change go 1.22 to go 1.23 in my go.mod file I have following output

$ go install -a golang.org/x/tools/cmd/stringer@latest
$ stringer -type=MessageStatus -trimprefix=MessageStatus
stringer: no value for constant MessageStatusSuccess

In case if I rollback my changes it works fine:
$ git checkout -- ../../../go.mod
$ stringer -type=MessageStatus -trimprefix=MessageStatus

What did you see happen?

I have following code:

const (
	MessageStatusSuccess MessageStatus = iota
	// All codes below are considered as errors
        ...
)

type MessageStatus uint32

I run stringer with go 1.22 specified in go.mod and it works fine. After I change it to Go 1.23 it started to fail with unclear error.

What did you expect to see?

stringer works with go 1.23

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions