go CLI解决方案最佳实践

The best practice of CLI solution in go

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

在没有 cgo 的情况下是否有其他解决方案,用户不需要额外安装 GNU readline

我使用了 github.com/peterh/liner 的线性库,并取得了一些成功。

它是一个纯 Go 包,不依赖于 readline,可以在 windows/linux/os x 上运行。

有关详细信息,请参阅 docs


还有github.com/chzyer/readline which looks very competent too - but I haven't tried that one. Docs are here.