xgo: Unsupported: Package level var MyStruct[GenericType] = {instantiation of struct}
Using go 1.24.4.
To fix build: the instantiation has to be moved to an init() or a Setup func.
go tool xgo test -v ./providers/blockbook
# arculus.com/Arculus-Cloud/types
types/arculus-structs.go:205: cannot use generic type ReqBody[T any] without instantiation
types/arculus-structs.go:250: cannot use generic type ReqBody[T any] without instantiation
types/arculus-structs.go:342: cannot use generic type ReqBody[T any] without instantiation
# arculus.com/Arculus-Cloud/keydb
keydb/keydb.go:44: cannot use generic type task.Tasker[Client any] without instantiation
FAIL arculus.com/Arculus-Cloud/providers/blockbook [build failed]
FAIL
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 20 (10 by maintainers)
@xhd2015 tested and working on my demo package! And confirmed working in our main codebase. Thanks so much for quickly addressing my issues, and thank you for your extremely useful project. Looking forward to what comes next!
released: https://github.com/xhd2015/xgo/releases/tag/v1.1.9
nice work! I’ll check ASAP
@pspencer-arculus can you check the code in
.xgo/gen/overlay/PROJECT/database/chainlist/chainlist.go:21, which is the rewritten content of the original file.Can give a minimal reproducible example if possible, thanks.
Reproduce this with:
And check the rewrite file inside
./.xgo:The return type of
instance_xgo_getlacks generic param forWrapperDebugging command:
Aha, a good point, I think it’s related to variable mocking, https://github.com/xhd2015/xgo/blob/master/runtime/test/mock/mock_var/mock_var_test.go
I’ll add a test for this and fix it, thanks for feedback!
I refactored my code to make xgo work and I think your project is amazing 😃