{"action":"created","issue":{"url":"https://api.github.com/repos/golang/mock/issues/77","repository_url":"https://api.github.com/repos/golang/mock","labels_url":"https://api.github.com/repos/golang/mock/issues/77/labels{/name}","comments_url":"https://api.github.com/repos/golang/mock/issues/77/comments","events_url":"https://api.github.com/repos/golang/mock/issues/77/events","html_url":"https://github.com/golang/mock/issues/77","id":237406091,"number":77,"title":"mock does not import the source file","user":{"login":"junghoahnsc","id":20134198,"avatar_url":"https://avatars3.githubusercontent.com/u/20134198?v=4","gravatar_id":"","url":"https://api.github.com/users/junghoahnsc","html_url":"https://github.com/junghoahnsc","followers_url":"https://api.github.com/users/junghoahnsc/followers","following_url":"https://api.github.com/users/junghoahnsc/following{/other_user}","gists_url":"https://api.github.com/users/junghoahnsc/gists{/gist_id}","starred_url":"https://api.github.com/users/junghoahnsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/junghoahnsc/subscriptions","organizations_url":"https://api.github.com/users/junghoahnsc/orgs","repos_url":"https://api.github.com/users/junghoahnsc/repos","events_url":"https://api.github.com/users/junghoahnsc/events{/privacy}","received_events_url":"https://api.github.com/users/junghoahnsc/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2017-06-21T03:38:23Z","updated_at":"2018-04-06T18:24:30Z","closed_at":"2018-04-03T23:21:27Z","author_association":"NONE","body":"I'm trying to generate a mock from a source.\r\n```\r\n$ cat x.go\r\npackage test\r\n\r\ntype X struct{}\r\n\r\ntype S interface {\r\n\tF(X)\r\n}\r\n```\r\n```\r\n$ mockgen -source x.go\r\n// Automatically generated by MockGen. DO NOT EDIT!\r\n// Source: x.go\r\n\r\npackage mock_test\r\n\r\nimport (\r\n\tgomock \"github.com/golang/mock/gomock\"\r\n)\r\n\r\n// Mock of S interface\r\ntype MockS struct {\r\n\tctrl     *gomock.Controller\r\n\trecorder *_MockSRecorder\r\n}\r\n\r\n// Recorder for MockS (not exported)\r\ntype _MockSRecorder struct {\r\n\tmock *MockS\r\n}\r\n\r\nfunc NewMockS(ctrl *gomock.Controller) *MockS {\r\n\tmock := &MockS{ctrl: ctrl}\r\n\tmock.recorder = &_MockSRecorder{mock}\r\n\treturn mock\r\n}\r\n\r\nfunc (_m *MockS) EXPECT() *_MockSRecorder {\r\n\treturn _m.recorder\r\n}\r\n\r\nfunc (_m *MockS) F(_param0 X) {\r\n\t_m.ctrl.Call(_m, \"F\", _param0)\r\n}\r\n\r\nfunc (_mr *_MockSRecorder) F(arg0 interface{}) *gomock.Call {\r\n\treturn _mr.mock.ctrl.RecordCall(_mr.mock, \"F\", arg0)\r\n}\r\n```\r\n\r\nThe generated mock does not import the original source for the type `X`.\r\nShould I edit the generated mock? I tried some flags like `-imports`, but it didn't work.\r\n\r\nThanks,"},"comment":{"url":"https://api.github.com/repos/golang/mock/issues/comments/379336852","html_url":"https://github.com/golang/mock/issues/77#issuecomment-379336852","issue_url":"https://api.github.com/repos/golang/mock/issues/77","id":379336852,"user":{"login":"junghoahnsc","id":20134198,"avatar_url":"https://avatars3.githubusercontent.com/u/20134198?v=4","gravatar_id":"","url":"https://api.github.com/users/junghoahnsc","html_url":"https://github.com/junghoahnsc","followers_url":"https://api.github.com/users/junghoahnsc/followers","following_url":"https://api.github.com/users/junghoahnsc/following{/other_user}","gists_url":"https://api.github.com/users/junghoahnsc/gists{/gist_id}","starred_url":"https://api.github.com/users/junghoahnsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/junghoahnsc/subscriptions","organizations_url":"https://api.github.com/users/junghoahnsc/orgs","repos_url":"https://api.github.com/users/junghoahnsc/repos","events_url":"https://api.github.com/users/junghoahnsc/events{/privacy}","received_events_url":"https://api.github.com/users/junghoahnsc/received_events","type":"User","site_admin":false},"created_at":"2018-04-06T18:24:30Z","updated_at":"2018-04-06T18:24:30Z","author_association":"NONE","body":"sure, it's same as you did.\r\n\r\n```\r\n$ cat x.go\r\npackage test\r\n\r\ntype S interface {\r\n\tF(X)\r\n}\r\n\r\n$ cat y.go\r\npackage test\r\n\r\ntype X struct{}\r\n\r\n$ mockgen -source x.go -aux_files test=y.go\r\n// Code generated by MockGen. DO NOT EDIT.\r\n// Source: x.go\r\n\r\n// Package mock_test is a generated GoMock package.\r\npackage mock_test\r\n\r\nimport (\r\n\tgomock \"github.com/golang/mock/gomock\"\r\n\treflect \"reflect\"\r\n)\r\n\r\n// MockS is a mock of S interface\r\ntype MockS struct {\r\n\tctrl     *gomock.Controller\r\n\trecorder *MockSMockRecorder\r\n}\r\n\r\n// MockSMockRecorder is the mock recorder for MockS\r\ntype MockSMockRecorder struct {\r\n\tmock *MockS\r\n}\r\n\r\n// NewMockS creates a new mock instance\r\nfunc NewMockS(ctrl *gomock.Controller) *MockS {\r\n\tmock := &MockS{ctrl: ctrl}\r\n\tmock.recorder = &MockSMockRecorder{mock}\r\n\treturn mock\r\n}\r\n\r\n// EXPECT returns an object that allows the caller to indicate expected use\r\nfunc (m *MockS) EXPECT() *MockSMockRecorder {\r\n\treturn m.recorder\r\n}\r\n\r\n// F mocks base method\r\nfunc (m *MockS) F(arg0 X) {\r\n\tm.ctrl.Call(m, \"F\", arg0)\r\n}\r\n\r\n// F indicates an expected call of F\r\nfunc (mr *MockSMockRecorder) F(arg0 interface{}) *gomock.Call {\r\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"F\", reflect.TypeOf((*MockS)(nil).F), arg0)\r\n}\r\n```"}}
{"actor":{"display_login":"junghoahnsc"}}