Writing a skill in Go

Go is my preferred language for most things. Is it possible to use go instead of python? if not, what changes it would take to make it so?

Also, in the meanwhile, can I call a go library from python? Google gave me this but I am curious if anyone think it’s a good idea -

Anything with websockets can interact with mycroft as a skill. There will be a bit of an uphill struggle while translating the methods used in the MycroftSkill class and hooking it up to the message bus, but I’d say it’s definitely doable.

why do we need websockets? can i replace the __init__.py with go file or a go executable? If not, what kind of changes should be made in mycroft-core to support this?

The skills communicate with the rest of the system over a local websocket message bus. Basically you will need to rewrite the entire skill process core.py and maybe container.py in the mycroft/skills directory) to a go skill processes for running go skills.

Alternatively, I think go is C abi compatible (or whatever the technical term is) so you could create your methods and have a python shiv (__init__.py) calling your compiled go code using ctypes. Basically you would need a skill skeleton that registers the intents and then intent handlers that only executes your go code.


I am just curious, what is the reason that it uses websocket? is there any advantage over the alternatives?
Also, do you think that using ctypes will decrease the performance of the skill?

The messagebus/websockets was an early decision (way before my time in the project) and was made to create a more modular software. Anything can quite easily be added to the system or be replaced by a new component. This will be slower than keeping a big monolithic approach but much easier to work with and for the community to incorporate in their own projects.

Are there any specific alternatives you’re thinking of?

Ctypes will not affect performance much, there is a bridge between python and the go-library but the binary code in the library will execute much faster than python so it’ll probably even out.