Skip to content
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

client-gen generates empty files when using Go 1.23 #176

Open
JRBANCEL opened this issue Aug 13, 2024 · 4 comments
Open

client-gen generates empty files when using Go 1.23 #176

JRBANCEL opened this issue Aug 13, 2024 · 4 comments

Comments

@JRBANCEL
Copy link

We use client-gen like this:

client-gen \
        --input-base "github.com/<WHATEVER>/pkg/apis" \
        --input "dedicated/v1alpha1" \
        --output-pkg github.com/<WHATEVER>/pkg/clientset \
        --go-header-file hack/header.txt \
        --clientset-name versioned \
        --output-dir ./pkg/clientset

Works fine in 1.22.0 (and v0.30.1).

Now, when I bump go.mod to use 1.23.0, client-gen generates files with just the package statement:

// Code generated by client-gen. DO NOT EDIT.

package v1alpha1

Output with -v 10 doesn't show anything interesting.
I tried to update client-gen to v0.31.0, same result.

@Airblader
Copy link

Several people in my team have the same issue with tooling like deepcopy-gen. Oddly, though, for me it seems to work.

@luca-filipponi
Copy link

@JRBANCEL try to clean the go mod cache go clean -modcache, this worked for us

@zaininHub
Copy link

go mod cache clean doesnt help, has any solution else?

@dpeckett
Copy link

dpeckett commented Dec 3, 2024

What's happening here is that code-generator needs to built with the same major.minor version of Go as your project (due to the way it hooks into the go toolchain). If you use go install or go run it will automatically downgrade to the toolchain version in the code-generator go.mod.

To fix this, just export GOTOOLCHAIN=go1.23.3 or whatever version is appropriate before running go install / go run.

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

No branches or pull requests

5 participants