golang/mock

Generic generation failed without specifying source

songzhibin97 opened this issue · 1 comments

  1. template code
package mock

import "github.com/songzhibin97/gkit/timeout"

type TestInterface interface {
	Call() Generics[timeout.DbJSON]
}

type Generics[T any] struct {
	generics *T
}
  1. use comment
mockgen -destination=./mocks/test.go -package=mocks . TestInterface
  1. result
 Failed to format generated source code: ./mocks/test.go:37:60: missing ',' in type argument list (and 1 more errors)
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/golang/mock (interfaces: TestInterface)

// Package mocks is a generated GoMock package.
package mocks

import (
        reflect "reflect"
        mock "github.com/golang/mock"
        gomock "github.com/golang/mock/gomock"
)

// MockTestInterface is a mock of TestInterface interface.
type MockTestInterface struct {
        ctrl     *gomock.Controller
        recorder *MockTestInterfaceMockRecorder
}

// MockTestInterfaceMockRecorder is the mock recorder for MockTestInterface.
type MockTestInterfaceMockRecorder struct {
        mock *MockTestInterface
}

// NewMockTestInterface creates a new mock instance.
func NewMockTestInterface(ctrl *gomock.Controller) *MockTestInterface {
        mock := &MockTestInterface{ctrl: ctrl}
        mock.recorder = &MockTestInterfaceMockRecorder{mock}
        return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockTestInterface) EXPECT() *MockTestInterfaceMockRecorder {
        return m.recorder
}

// Call mocks base method.
func (m *MockTestInterface) Call() mock.Generics[github.com/songzhibin97/gkit/timeout.DbJSON] {
        m.ctrl.T.Helper()
        ret := m.ctrl.Call(m, "Call")
        ret0, _ := ret[0].(mock.Generics[github.com/songzhibin97/gkit/timeout.DbJSON])
        return ret0
}

// Call indicates an expected call of Call.
func (mr *MockTestInterfaceMockRecorder) Call() *gomock.Call {
        mr.mock.ctrl.T.Helper()
        return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Call", reflect.TypeOf((*MockTestInterface)(nil).Call))
}