Skip to content

x/tools/cmd/stringer: internal error: package "database/sql/driver" without types was imported #72744

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
StrangeYear opened this issue Mar 8, 2025 · 4 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@StrangeYear
Copy link

StrangeYear commented Mar 8, 2025

Go version

go version go1.24.1 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE='on'
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/admin/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/admin/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/k9/3dqg8jt93j5f_q_kbfh1jbh00000gn/T/go-build269056108=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/admin/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/admin/go'
GOPROXY='https://goproxy.io,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/admin/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.1'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

package enums

import (
	"database/sql/driver"

	"github.com/gogf/gf/v2/util/gconv"
)

//go:generate stringer -type DictValueType -linecomment -output dict_string.go
type DictValueType int

func (t DictValueType) Value() (driver.Value, error) {
	return int64(t), nil
}

func (t *DictValueType) Scan(src interface{}) error {
	if value, ok := src.(int64); ok {
		*t = DictValueType(value)
		return nil
	}
	if value, ok := src.([]uint8); ok {
		*t = DictValueType(gconv.Int64(string(value)))
		return nil
	}
	return nil
}

const (
	StringDictValueType   DictValueType = iota // String
	NumberDictValueType                        // Number
	BooleanDictValueType                       // Boolean
	DateDictValueType                          // Date
	DatetimeDictValueType                      // Datetime
	JSONDictValueType                          // JSON
)

What did you see happen?

When I was using Go version 1.23, this could be generated normally. However, after I upgraded to version 1.24, it no longer generates correctly and throws an error.

stringer: internal error: package "database/sql/driver" without types was imported from "web-server/internal/enums"
enums.go:9: running "stringer": exit status 1

What did you expect to see?

The expectation is for the code to be generated normally.

@seankhliao
Copy link
Member

what version of stringer?

@seankhliao seankhliao changed the title bug: stringer: internal error: package "database/sql/driver" without types was imported x/tools/cmd/stringer: internal error: package "database/sql/driver" without types was imported Mar 8, 2025
@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 8, 2025
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Mar 8, 2025
@gopherbot gopherbot added this to the Unreleased milestone Mar 8, 2025
@StrangeYear
Copy link
Author

what version of stringer?

golang.org/x/tools v0.31.0

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Mar 8, 2025
@StrangeYear
Copy link
Author

I have resolved the issue; after deleting the stringer binary file and reinstalling it, everything works fine now. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants