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

Generation failure on go 1.23 with type aliases #22

Open
deefdragon opened this issue Aug 17, 2024 · 2 comments
Open

Generation failure on go 1.23 with type aliases #22

deefdragon opened this issue Aug 17, 2024 · 2 comments

Comments

@deefdragon
Copy link

When using go toolchain 1.23.0 and go version 1.23, interfaces with methods that has an aliased type as an argument will fail to generate with the following error

[debug] loadPackages took 32.180249ms
[debug] resolvePackagePath took 11.411105ms
Error: generating circuit wrapper: resolvePkgPaths: invalid type: <module>/api.TestAlias

(The file was not in the module root, but in the /api folder, so I would have expected the path to be <module>/api/api.TestAlias)

This is the smallest example I could create, and produced the above error.

package api

import (
	"context"
)

type TestInterface interface {
	SomeFunc(ctx context.Context, body TestAlias) (*int, error)
}

type TestAlias = TestBase

type TestBase struct {
	Foo int
}

Command used to generate:
go run github.com/twitchtv/circuitgen --name TestInterface --pkg ./ --debug --out ./circuit.gen.go --alias TestCircuit --circuit-major-version 3

@deefdragon
Copy link
Author

deefdragon commented Aug 17, 2024

This is a consiquence of the go 1.23 change to go/types

By default, go/types now produces Alias type nodes for type aliases

I was able to resolve this by adding case *types.Alias: to resolvePkgPaths' breakout cases locally. It should also be temporarily resolvable by setting GODEBUG=gotypesalias=0

@deefdragon
Copy link
Author

I attempted to do the quick fix I mentioned, but testing was not running due to errorcheck panic-ing. Even bypassing it, I was running into other issues getting the generation to properly execute. I think there are deeper issues around the more modern versions of go.

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

1 participant