Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Generic generation failed without specifying source #681

Open
songzhibin97 opened this issue Oct 27, 2022 · 1 comment
Open

Generic generation failed without specifying source #681

songzhibin97 opened this issue Oct 27, 2022 · 1 comment

Comments

@songzhibin97
Copy link

  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))
}
@tra4less
Copy link
Contributor

tra4less commented Dec 5, 2022

see #669

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants