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

Generic generation failed without specifying source #681

@songzhibin97

Description

@songzhibin97
  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))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions