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

go:generate bug #515

Closed
ahl5esoft opened this issue Jan 30, 2021 · 2 comments · Fixed by #507
Closed

go:generate bug #515

ahl5esoft opened this issue Jan 30, 2021 · 2 comments · Fixed by #507

Comments

@ahl5esoft
Copy link

ahl5esoft commented Jan 30, 2021

// i-subscriber.go
//go:generate mockgen -destination i-subscriber_mock.go -package pubsub my-go/plugin/pubsub ISubscriber

package pubsub

// Message is subscribe message
type Message struct {
	Channel string
	Text    string
}

// ISubscriber is subscriber interface
type ISubscriber interface {
	Subscribe(channels []string, message chan<- Message)
	Unsubscribe(channels ...string) error
}
// i-subscriber_mock.go
// Code generated by MockGen. DO NOT EDIT.
// Source: my-go/plugin/pubsub (interfaces: ISubscriber)

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

import (
	pubsub "my-go/plugin/pubsub"
	gomock "github.com/golang/mock/gomock"
	reflect "reflect"
)

// MockISubscriber is a mock of ISubscriber interface
type MockISubscriber struct {
	ctrl     *gomock.Controller
	recorder *MockISubscriberMockRecorder
}

// MockISubscriberMockRecorder is the mock recorder for MockISubscriber
type MockISubscriberMockRecorder struct {
	mock *MockISubscriber
}

// NewMockISubscriber creates a new mock instance
func NewMockISubscriber(ctrl *gomock.Controller) *MockISubscriber {
	mock := &MockISubscriber{ctrl: ctrl}
	mock.recorder = &MockISubscriberMockRecorder{mock}
	return mock
}

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

// Subscribe mocks base method
func (m *MockISubscriber) Subscribe(arg0 []string, arg1 chan<- pubsub.Message) {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "Subscribe", arg0, arg1)
}

// Subscribe indicates an expected call of Subscribe
func (mr *MockISubscriberMockRecorder) Subscribe(arg0, arg1 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Subscribe", reflect.TypeOf((*MockISubscriber)(nil).Subscribe), arg0, arg1)
}

// Unsubscribe mocks base method
func (m *MockISubscriber) Unsubscribe(arg0 ...string) error {
	m.ctrl.T.Helper()
	varargs := []interface{}{}
	for _, a := range arg0 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "Unsubscribe", varargs...)
	ret0, _ := ret[0].(error)
	return ret0
}

// Unsubscribe indicates an expected call of Unsubscribe
func (mr *MockISubscriberMockRecorder) Unsubscribe(arg0 ...interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unsubscribe", reflect.TypeOf((*MockISubscriber)(nil).Unsubscribe), arg0...)
}

the i-subscriber_mock.go's code contains references to the same package code pubsub "my-go/plugin/pubsub"

@codyoss
Copy link
Member

codyoss commented Feb 5, 2021

Investigating this.

As a workaround, source mode will work: mockgen -destination i-subscriber_mock.go -package pubsub -source i-subscriber.go

@codyoss
Copy link
Member

codyoss commented Feb 5, 2021

I confirmed that the purposed change should fix this.

codyoss added a commit that referenced this issue Feb 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants