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.
mockgen source mode does not work with go1.11 modules #230
Closed
Description
"self" import is generates as x "."
. It works in gopath and with reflection based mockgen
.
Using -self_package
does not affect the output.
Sample program (foo.go):
package foo
type Arg struct {}
type Foo interface {
Bar(a Arg) error
}
Used command:
$ mockgen -source=foo.go
Generated output:
// Code generated by MockGen. DO NOT EDIT.
// Source: foo.go
// Package mock_foo is a generated GoMock package.
package mock_foo
import (
x "."
gomock "github.com/golang/mock/gomock"
reflect "reflect"
)
// MockFoo is a mock of Foo interface
type MockFoo struct {
ctrl *gomock.Controller
recorder *MockFooMockRecorder
}
// MockFooMockRecorder is the mock recorder for MockFoo
type MockFooMockRecorder struct {
mock *MockFoo
}
// NewMockFoo creates a new mock instance
func NewMockFoo(ctrl *gomock.Controller) *MockFoo {
mock := &MockFoo{ctrl: ctrl}
mock.recorder = &MockFooMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockFoo) EXPECT() *MockFooMockRecorder {
return m.recorder
}
// Bar mocks base method
func (m *MockFoo) Bar(a x.Arg) error {
ret := m.ctrl.Call(m, "Bar", a)
ret0, _ := ret[0].(error)
return ret0
}
// Bar indicates an expected call of Bar
func (mr *MockFooMockRecorder) Bar(a interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bar", reflect.TypeOf((*MockFoo)(nil).Bar), a)
}
Versions:
go version go1.11.2 darwin/amd64
mockgen latest version