gocommand-line-interfacereadlinelibreadline

The best practice of CLI solution in go


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?


Solution

  • 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.