Skip to content

stringer: internal error: package "strconv" without types was imported from XXX #64813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
WittonBell opened this issue Dec 20, 2023 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@WittonBell
Copy link

WittonBell commented Dec 20, 2023

Go version

go version go1.21.4 windows/amd64

What operating system and processor architecture are you using (go env)?

set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\admin\AppData\Local\go-build
set GOENV=C:\Users\admin\AppData\Roaming\go\env  
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\admin\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\admin\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=G:/msys64/mingw64/lib/go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=G:\msys64\mingw64\lib\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.4
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=D:\Server\go.work
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\admin\AppData\Local\Temp\go-build2587774622=/tmp/go-build -gno-record-gcc-switches

What did you do?

eitem.go:

package enums

//go:generate stringer -type=EItemSource
type EItemSource uint16

const (
	ItemSourceNone EItemSource = 0 + iota

	ItemSourceInit
)

run go generate, report error when already generated output file:
stringer: internal error: package "strconv" without types was imported from "enums" eitem.go:3: running "stringer": exit status 1

so, it is not work fine if run go generate multiple times.

I remember old version(maybe go 1.1X) is work fine.

What did you expect to see?

no error report and output normally.

What did you see instead?

run go generate, report error when already generated output file:
stringer: internal error: package "strconv" without types was imported from "enums" eitem.go:3: running "stringer": exit status 1

@mauri870 mauri870 added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 20, 2023
@mauri870
Copy link
Member

I was unable to reproduce this, it is a Possible duplicate of #52710. Can you try the steps provided in the issue and see if it fixes the problem for you? Thanks.

@mauri870 mauri870 added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 20, 2023
@WittonBell
Copy link
Author

@mauri870 I try go clean -cache, go clean -modcache and go install golang.org/x/tools/cmd/stringer@latest, then work fine.

I used go install golang.org/x/tools/cmd/stringer before, maybe not installed the latest version.

By the way, it's maybe better output filename with origin file append _string, for example, XXX.go output XXX_string.go when not specify output filename.

Thanks.

@mauri870
Copy link
Member

You can customize the output file with the -output option, per https://pkg.go.dev/golang.org/x/tools/cmd/stringer docs:

The -type flag accepts a comma-separated list of types so a single run can generate methods for multiple types. The default output file is t_string.go, where t is the lower-cased name of the first type listed. It can be overridden with the -output flag.

I'm glad that fixed the issue for you, I'm closing this as a duplicate of the other issue.

@mauri870
Copy link
Member

Duplicate of #52710

@mauri870 mauri870 marked this as a duplicate of #52710 Dec 20, 2023
@mauri870 mauri870 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2023
@golang golang locked and limited conversation to collaborators Dec 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants