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

support imported type aliases #225

Merged
merged 3 commits into from
Aug 24, 2024
Merged

support imported type aliases #225

merged 3 commits into from
Aug 24, 2024

Conversation

reillywatson
Copy link
Contributor

Go 1.23 changed how go/types handles type aliases, which breaks code generation if you use a package that has an alias type (example: https://pkg.go.dev/github.com/golang/[email protected]/ptypes/timestamp#Timestamp). These were getting generated as just the unqualified name, without the package. If you used a previous version of Go, it meant that if that aliased type was in an internal package we'd try to import the internal package instead, resulting in a compilation error.

Add a switch to handle that case, and bump the go.mod version to support using types.Alias.

Go 1.23 changed how go/types handles type aliases, which breaks code generation if you use a package that has an alias type (example: https://pkg.go.dev/github.com/golang/[email protected]/ptypes/timestamp#Timestamp). These were getting generated as just the unqualified name, without the package. If you used a previous version of Go, it meant that if that aliased type was in an internal package we'd try to import the internal package instead, resulting in a compilation error.

Add a switch to handle that case, and bump the go.mod version to support using types.Alias.
pkg/moq/moq_test.go Outdated Show resolved Hide resolved
@sudo-suhas sudo-suhas merged commit 5dfcd56 into matryer:main Aug 24, 2024
4 checks passed
@sudo-suhas
Copy link
Collaborator

Thanks @reillywatson for the PR! Changes have been released in [email protected]

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