{"action":"opened","issue":{"url":"https://api.github.com/repos/hybridgroup/gobot/issues/625","repository_url":"https://api.github.com/repos/hybridgroup/gobot","labels_url":"https://api.github.com/repos/hybridgroup/gobot/issues/625/labels{/name}","comments_url":"https://api.github.com/repos/hybridgroup/gobot/issues/625/comments","events_url":"https://api.github.com/repos/hybridgroup/gobot/issues/625/events","html_url":"https://github.com/hybridgroup/gobot/issues/625","id":364441692,"node_id":"MDU6SXNzdWUzNjQ0NDE2OTI=","number":625,"title":"How would you \"abstract\" the readable devices?","user":{"login":"lucavallin","id":14332663,"node_id":"MDQ6VXNlcjE0MzMyNjYz","avatar_url":"https://avatars1.githubusercontent.com/u/14332663?v=4","gravatar_id":"","url":"https://api.github.com/users/lucavallin","html_url":"https://github.com/lucavallin","followers_url":"https://api.github.com/users/lucavallin/followers","following_url":"https://api.github.com/users/lucavallin/following{/other_user}","gists_url":"https://api.github.com/users/lucavallin/gists{/gist_id}","starred_url":"https://api.github.com/users/lucavallin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucavallin/subscriptions","organizations_url":"https://api.github.com/users/lucavallin/orgs","repos_url":"https://api.github.com/users/lucavallin/repos","events_url":"https://api.github.com/users/lucavallin/events{/privacy}","received_events_url":"https://api.github.com/users/lucavallin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-27T12:02:12Z","updated_at":"2018-09-27T12:02:12Z","closed_at":null,"author_association":"NONE","body":"To overcome boilerplate I'd like to do something like this (or in the future use something like an abstract factory)\r\n\r\n```\r\n\tvar sensors map[string]gobot.Device\r\n\tsensors[\"sound\"] = aio.NewGroveSoundSensorDriver(gp, \"A0\")\r\n\tsensors[\"temperature\"] = aio.NewGroveTemperatureSensorDriver(gp, \"A1\")\r\n\tsensors[\"light\"] = aio.NewGroveLightSensorDriver(gp, \"A2\")\r\n\r\n\twork := func() {\r\n\t\tgobot.Every(timeInterval, func() {\r\n\t\t\tfor name, driver := range sensors {\r\n\t\t\t\tval, _ := driver.Read()\r\n\t\t\t\tjson, _:= json.Marshal(messages.NewReading(name, val))\r\n\t\t\t\tmqttAdaptor.Publish(\"from\", json)\r\n\t\t\t}\r\n\t\t})\r\n\t}\r\n```\r\n\r\nObviously this won't compile because gobot.Device doesn't have a Read() method. Any idea?"}}
{"actor":{"display_login":"lucavallin"}}