英文:
How to make a chatbot in Golang with dynamic plugins and adapters?
问题
我是新手学习 Golang,并且正在编写一个聊天机器人作为练习。
基本上,我正在使用 net/http 和 gorilla/mux 来处理请求。
目前,它只能与一个特定的聊天平台进行对话(我称之为适配器),并且只有一个插件(在谷歌上查找图片)。
我应该如何使适配器和插件都具有动态性,以便其他开发人员可以编写自己的内容并将我的机器人作为基础平台使用?有没有好的示例?
另外,我应该将所有的插件和适配器放在一个仓库/静态二进制文件中,还是应该将它们分开?我知道两种方式都可以,但你会推荐哪种方式以便更容易进行协作和扩展性?
英文:
I'm new to Golang and writing a chat bot as an exercise.
Basically I'm using net/http and gorilla/mux to handle requests.
For now it can only talk to one specific chat platform (I call it an adapter) and has only one plugin (find a picture on google).
How can I make both adapters and plugins be dynamic - so other developers can write their own stuff and just use my bot as a base platform? Are there any good examples?
Also should I have all the plugins and adapters in one repo/static binary or should they be separate? I know I can do both ways but what would you recommend as a better way to have easier collaboration and extensibility?
答案1
得分: 1
《Medium帖子,“标准包布局”》(https://medium.com/@benbjohnson/standard-package-layout-7cdbc8391fc1),作者是Ben Johnson,这篇文章帮助我思考了这个问题。
英文:
Medium post, "Standard Package Layout", by Ben Johnson, helped me think about this.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论