在Go语言中,CLI解决方案的最佳实践是什么?

huangapple go评论76阅读模式
英文:

The best practice of CLI solution in go

问题

我想实现一个提供类似交互式Shell的CLI体验的程序。
我一直在尝试使用https://github.com/bobappleyard/readline,但它需要用户安装GNU readline,并且在OSX上会导致一些错误。

是否有其他在Go中实现的解决方案,而不需要用户额外安装GNU readlinecgo呢?

英文:

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.

huangapple
  • 本文由 发表于 2015年10月2日 16:37:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/32903396.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定