Skip to content

Conversation

@gstarikov
Copy link
Contributor

I have a problem. My project uses golang.org/x/tools version 0.35.0, but goverter is stuck at version 0.25.0. We use goverter in a build pipeline, and there is a tool conflict - go run goverter returns the error "... imported ... without packages..."

@jmattheis
Copy link
Owner

Provide an example how to reproduce this in a clean project.

@gstarikov
Copy link
Contributor Author

gstarikov commented Jul 24, 2025

yes, it was not trivial. I tried to reproduce it for a very long time in a clean project. but something worked out.
but, looks like i found a workaround

go.mod

module example.com/issue

go 1.24.5

require github.com/stephenafamo/bob v0.38.0

require (
	github.com/aarondl/json v0.0.0-20221020222930-8b0db17ef1bf // indirect
	github.com/aarondl/opt v0.0.0-20230114172057-b91f370c41f0 // indirect
	github.com/dave/jennifer v1.6.0 // indirect
	github.com/jmattheis/goverter v1.9.0 // indirect
	github.com/qdm12/reprint v0.0.0-20200326205758-722754a53494 // indirect
	github.com/stephenafamo/scan v0.7.0 // indirect
	golang.org/x/mod v0.26.0 // indirect
	golang.org/x/sync v0.16.0 // indirect
	golang.org/x/tools v0.35.0 // indirect
)

tool github.com/jmattheis/goverter/cmd/goverter

converter.go

package govertertest

import (
	_ "example.com/issue/model"
)

model/model.go

package model

import (
	"github.com/stephenafamo/bob"
	"github.com/stephenafamo/bob/dialect/psql"
	"github.com/stephenafamo/bob/dialect/psql/dialect"
)

type Bob struct{}
type BobSlice []*Bob
var Bobs = psql.NewTablex[*Bob, BobSlice, *BobSetter]("", "bob")
type BobSetter struct{}
func (b BobSetter) SetColumns() []string { return nil }
func (b BobSetter) Apply(*dialect.InsertQuery) { return }
func (b BobSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] { return nil }

so, the issue:

$ go run github.com/jmattheis/goverter/cmd/goverter@latest gen example.com/issue
2025/07/24 06:36:53 internal error: package "example.com/issue/model" without types was imported from "example.com/issue"
exit status 1

the workaround

$ go get -tool github.com/jmattheis/goverter/cmd/goverter@latest
$ go tool goverter gen example.com/issue

and in a real project this workaround generates files just as well as my bumpedup version

PS.
the bumpedup version still works

$ go run github.com/gstarikov/goverter/cmd/goverter@hotfix gen example.com/issue

@jmattheis jmattheis force-pushed the bump-golang.org/x/tools-v0.35.0 branch from 44ecb85 to af8aa76 Compare July 25, 2025 13:23
@codecov
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.46%. Comparing base (56a34ec) to head (af8aa76).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #208   +/-   ##
=======================================
  Coverage   95.46%   95.46%           
=======================================
  Files          49       49           
  Lines        3243     3243           
=======================================
  Hits         3096     3096           
  Misses        114      114           
  Partials       33       33           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jmattheis
Copy link
Owner

Thanks for the detailed steps. I've changed this to update only to x/tools v0.31.0 to support building with go1.23.

@jmattheis jmattheis merged commit ddfe50c into jmattheis:main Jul 25, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants