{"action":"closed","issue":{"url":"https://api.github.com/repos/golang/mock/issues/247","repository_url":"https://api.github.com/repos/golang/mock","labels_url":"https://api.github.com/repos/golang/mock/issues/247/labels{/name}","comments_url":"https://api.github.com/repos/golang/mock/issues/247/comments","events_url":"https://api.github.com/repos/golang/mock/issues/247/events","html_url":"https://github.com/golang/mock/issues/247","id":387980747,"node_id":"MDU6SXNzdWUzODc5ODA3NDc=","number":247,"title":"mockgen: does not handle types if mocks are in test package","user":{"login":"poy","id":6554782,"node_id":"MDQ6VXNlcjY1NTQ3ODI=","avatar_url":"https://avatars2.githubusercontent.com/u/6554782?v=4","gravatar_id":"","url":"https://api.github.com/users/poy","html_url":"https://github.com/poy","followers_url":"https://api.github.com/users/poy/followers","following_url":"https://api.github.com/users/poy/following{/other_user}","gists_url":"https://api.github.com/users/poy/gists{/gist_id}","starred_url":"https://api.github.com/users/poy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poy/subscriptions","organizations_url":"https://api.github.com/users/poy/orgs","repos_url":"https://api.github.com/users/poy/repos","events_url":"https://api.github.com/users/poy/events{/privacy}","received_events_url":"https://api.github.com/users/poy/received_events","type":"User","site_admin":false},"labels":[{"id":223748955,"node_id":"MDU6TGFiZWwyMjM3NDg5NTU=","url":"https://api.github.com/repos/golang/mock/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-12-05T22:50:36Z","updated_at":"2018-12-21T06:32:21Z","closed_at":"2018-12-21T06:32:21Z","author_association":"COLLABORATOR","body":"It looks like mockgen doesn't attach the package name to a type if the package is set (via `--package`).\r\n\r\nExample:\r\n\r\nNotice in `mock_test.go` any usage of `User` does not have the package name `users`.\r\n\r\n**user.go**\r\n```go\r\npackage users\r\n\r\ntype User struct {\r\n\tName string\r\n}\r\n\r\ntype Finder interface {\r\n\tFindUser(name string) User\r\n}\r\n```\r\n\r\n```\r\nmockgen --source=user.go --destination=mock_test.go --package=users_test\r\n```\r\n\r\n**mock_test**\r\n```go\r\n// Code generated by MockGen. DO NOT EDIT.\r\n// Source: user.go\r\n\r\n// Package users_test is a generated GoMock package.\r\npackage users_test\r\n\r\nimport (\r\n\tgomock \"github.com/golang/mock/gomock\"\r\n\treflect \"reflect\"\r\n)\r\n\r\n// MockFinder is a mock of Finder interface\r\ntype MockFinder struct {\r\n\tctrl     *gomock.Controller\r\n\trecorder *MockFinderMockRecorder\r\n}\r\n\r\n// MockFinderMockRecorder is the mock recorder for MockFinder\r\ntype MockFinderMockRecorder struct {\r\n\tmock *MockFinder\r\n}\r\n\r\n// NewMockFinder creates a new mock instance\r\nfunc NewMockFinder(ctrl *gomock.Controller) *MockFinder {\r\n\tmock := &MockFinder{ctrl: ctrl}\r\n\tmock.recorder = &MockFinderMockRecorder{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 *MockFinder) EXPECT() *MockFinderMockRecorder {\r\n\treturn m.recorder\r\n}\r\n\r\n// FindUser mocks base method\r\nfunc (m *MockFinder) FindUser(name string) User {\r\n\tret := m.ctrl.Call(m, \"FindUser\", name)\r\n\tret0, _ := ret[0].(User)\r\n\treturn ret0\r\n}\r\n\r\n// FindUser indicates an expected call of FindUser\r\nfunc (mr *MockFinderMockRecorder) FindUser(name interface{}) *gomock.Call {\r\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"FindUser\", reflect.TypeOf((*MockFinder)(nil).FindUser), name)\r\n}\r\n```\r\n"}}
{"actor":{"display_login":"poy"}}