{"action":"closed","issue":{"url":"https://api.github.com/repos/facebookgo/inject/issues/4","labels_url":"https://api.github.com/repos/facebookgo/inject/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/facebookgo/inject/issues/4/comments","events_url":"https://api.github.com/repos/facebookgo/inject/issues/4/events","html_url":"https://github.com/facebookgo/inject/issues/4","id":87570057,"number":4,"title":"How to achieve substitution in tests with mocks if interface references cannot be injected?","user":{"login":"orospakr","id":16714,"avatar_url":"https://avatars.githubusercontent.com/u/16714?v=3","gravatar_id":"","url":"https://api.github.com/users/orospakr","html_url":"https://github.com/orospakr","followers_url":"https://api.github.com/users/orospakr/followers","following_url":"https://api.github.com/users/orospakr/following{/other_user}","gists_url":"https://api.github.com/users/orospakr/gists{/gist_id}","starred_url":"https://api.github.com/users/orospakr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orospakr/subscriptions","organizations_url":"https://api.github.com/users/orospakr/orgs","repos_url":"https://api.github.com/users/orospakr/repos","events_url":"https://api.github.com/users/orospakr/events{/privacy}","received_events_url":"https://api.github.com/users/orospakr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-12T01:46:57Z","updated_at":"2015-06-12T18:13:13Z","closed_at":"2015-06-12T18:13:13Z","body":"Like so many others before, I'd like to leverage the benefits of DI by using the same references on a struct I'm testing for manually set mock/stub structs in addition to having Inject populate them at normal runtime.\r\n\r\nHowever, in Golang, there's no Liskov-style substitution unless you're using interfaces.  The Inject doc mentions that \"supports injection for interface types as long as they’re unambiguous\", but I'm not sure what is meant there or if it's even relevant to this problem.\r\n\r\nI'd rather avoid having to manually create all such substitutable structs, because that means I'd have to create all such things at the top level, partially negating the value of using Inject (having a highly-polluted main()).\r\n\r\nPerhaps an extra parameter to the `inject` tag to indicate which object should be constructed to satisfy the interface requirement by default?"}}