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

Cannot regenerate fakes if they are relied upon and deleted - go1.19.10 #246

Open
waciumawanjohi opened this issue Jun 14, 2023 · 1 comment

Comments

@waciumawanjohi
Copy link

Go Version

1.19.10

Reproduction steps

# Clone an open source project using counterfeiter for testing
git clone https://github.com/vmware-tanzu/cartographer.git
cd cartographer

# Install go 1.19.10
go install golang.org/dl/go1.19.10@latest
go1.19.10 download

# Delete previously generated fakes
rm -rf pkg/repository/repositoryfakes/

# Run go generate
go1.19.10 generate ./pkg/repository

Expected result

Deleted files are recreated. Output:

Writing `FakeLogger` to `repositoryfakes/fake_logger.go`... Done
Writing `FakeRepoCache` to `repositoryfakes/fake_repo_cache.go`... Done
Writing `FakeClient` to `repositoryfakes/fake_client.go`... Done
Writing `FakeRepository` to `repositoryfakes/fake_repository.go`... Done

Observed result

Command errors. Output:

Writing `FakeLogger` to `repositoryfakes/fake_logger.go`... 
err: exit status 1: stderr: go build github.com/vmware-tanzu/cartographer/pkg/repository/repositoryfakes: cache_test.go:23:2: no required module provides package github.com/vmware-tanzu/cartographer/pkg/repository/repositoryfakes; to add it:
        go get github.com/vmware-tanzu/cartographer/pkg/repository/repositoryfakes

exit status 1
pkg/repository/repository.go:37: running "go": exit status 1

Comments

This workflow works when using go 1.19.9

You can cleanup the go downloads above by running

rm -rf $(go1.19.10 env GOROOT)
rm $(which go1.19.10)
@vmware-cartographer
Copy link

This problem is not observed when using go 1.20.5.

Workaround

Bump go to 1.20

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

2 participants