英文:
The best practice of CLI solution in go
问题
我想实现一个提供类似交互式Shell的CLI体验的程序。
我一直在尝试使用https://github.com/bobappleyard/readline,但它需要用户安装GNU readline
,并且在OSX上会导致一些错误。
是否有其他在Go中实现的解决方案,而不需要用户额外安装GNU readline
的cgo
呢?
英文:
I want to implement a program that provides interactive-shell like experience with CLI.
I have been trying https://github.com/bobappleyard/readline but it needs users to install GNU readline
and it causes some bugs in OSX.
Is there any other solution implemented in go without cgo
so users do not need to install GNU readline
additionally?
答案1
得分: 0
我已经成功地使用了来自github.com/peterh/liner的liner库。
它是一个纯Go包,在Windows/Linux/OS X上没有对readline的依赖。
更多信息请参阅文档。
还有一个看起来非常有竞争力的库github.com/chzyer/readline,但我还没有尝试过。文档在这里。
英文:
I've used the liner library from github.com/peterh/liner with some success for this.
It is a pure Go package with no dependencies on readline and works on windows/linux/os x.
See the docs for more info.
There is also github.com/chzyer/readline which looks very competent too - but I haven't tried that one. Docs are here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论