You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, adding (what I think is) a related finding to this issue.
I've found that when using direct embedding of an instantiated generic (e.g., Base[MyStruct]). Mockgen generates syntactically incorrect code by using the fully qualified package path for the type argument, instead of the local type.
Example:
package mypackage
// A generic function typetypeCallback[Tany] func(itemT)
// A generic base interfacetypeBase[Tany] interface {
OnEvent(callbackCallback[T])
}
// A concrete structtypeMyStructstruct {
}
// The interface to be mockedtypeMyInterfaceinterface {
Base[MyStruct]
}
Error: Failed to format generated source code: mypackage/my_interface.go missing ',' in type argument list
Generated Code:
// Uses the fully qualified path, which is a syntax errorfunc (m*MockMyInterface) OnEvent(arg0Callback[github.com/org/repo/mypackage.MyStruct]) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "OnEvent", arg0)
}
Expected::
// Should use the local type namefunc (m*MockMyInterface) OnEvent(arg0Callback[MyStruct]) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "OnEvent", arg0)
}
golang version: 1.25.2
gomock version: v0.6.0
Reacted by Ivan Ribakov, Víctor Arzoz and Meena Alfons
I've opened #326 to fix the original source-mode issue. The PR resolves embedded interface aliases and adds regression tests for the parser and generated mocks.
I also verified the package-mode example from #271 (comment). Mock generation and compilation already succeed for that example on current main
Activity
JuanBC9 commentedon Oct 24, 2025
Hi, adding (what I think is) a related finding to this issue.
I've found that when using direct embedding of an instantiated generic (e.g.,
Base[MyStruct]). Mockgen generates syntactically incorrect code by using the fully qualified package path for the type argument, instead of the local type.Example:
Error:
Failed to format generated source code: mypackage/my_interface.go missing ',' in type argument listGenerated Code:
Expected::
Bobrovskii commentedon Oct 14, 2026
I've opened #326 to fix the original source-mode issue. The PR resolves embedded interface aliases and adds regression tests for the parser and generated mocks.
I also verified the package-mode example from #271 (comment). Mock generation and compilation already succeed for that example on current
main