Gobot - troubles with events keyboard

Hi every one, well i have this code which one copy from the GOBOT’s documentation (https://gobot.io/documentation/drivers/keyboard/)


but when i try to run it, this show me the next error:

Hey @RafaelGopher,

It looks like maybe you meant to write gbot.On since you declared your gobot.NewGobot() as gbot.

Edit: After reading the documentation in the link you posted, I feel like this is probably not the issue since they are commonly using this method.

Can I ask, have you made sure to run go get github.com/hybridgroup/gobot/platforms/keyboard and go get github.com/hybridgroup/gobot before trying to compile and run this?

1 Like

According to a couple of code samples on gobot.io, there is a gobot.On() function available, but on godoc.org I do not see this function anywhere. Perhaps a doc bug?

1 Like

That’s why when I first replied and said to try gbot.On I ended up getting confused when I saw that heaps of the docs on the website used gobot.On :stuck_out_tongue:

2 Likes

yeah me too, i m confuse

I wonder if raising an issue might help clarifying this.

Actually you know what, I think if @RafaelGopher replaces gobot.On with gbot.On like I first suggested, it might work fine, since the Gobot struct composes with the Eventer interface which contains an On method.

Gobot struct
Eventer interface

@RafaelGopher, @christophberger, nevermind my last post!

They haven’t updated their docs by the looks of it because if you look here:
https://github.com/hybridgroup/gobot/tree/master/examples, the keyboard example (keyboard example) uses keys.On, instead of gobot.On since the Eventer interface runs based on the driver not on the actual gobot object.

@RafaelGopher, use the examples from their Github that I posted above because their docs need to be changed by the looks of things!

I just tested that example and it works perfectly!

Edit: I will try to make some pull requests to update their docs.

1 Like

I submitted a couple of pull requests to fix some of the docs that are now merged into the dev branch, so I’m guessing that when the dev branch gets merged into the master branch, then the changes will hopefully be updated on the gobot.io and godoc websites :slight_smile:

1 Like

Hats off!
Who would have guessed that there is a keys.On instead. This’ll teach me to dig deeper into the code next time :slight_smile:

2 Likes

Haha I know right! I actually just went on their Github and clicked on examples and noticed it was off from the docs :stuck_out_tongue: But I don’t even think I would have thought of that until you mentioned godoc :smiley:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.