Skip to content
Go package for ideal tty prompt
Go Makefile
Branch: master
Clone or download
Latest commit 548a7d7 Apr 3, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
_example Change directory name to ignore Jan 29, 2017
vendor/ Start using dep Jan 29, 2017
.gitignore Add ignore Dec 24, 2015
.travis.yml Use 1.8 Apr 2, 2017
Makefile Add -n1 Jan 29, 2017 Fix link Apr 23, 2017
ask.go Enable to mask defualt value Oct 17, 2016
input.go fix spelling; astarisk --> asterisk Apr 3, 2018
input_test.go Fix tests Mar 2, 2016
lock.json Start using dep Jan 29, 2017
manifest.json Start using dep Jan 29, 2017
read.go rename to be idiomatic Apr 10, 2017
read_test.go Handle space Oct 17, 2016
read_unix.go rename to be idiomatic Apr 10, 2017
read_windows.go rename to be idiomatic Apr 10, 2017
select.go Add hide option Mar 2, 2016
select_test.go Add Example Jan 14, 2016

go-input Go Documentation Travis MIT License

go-input is a Go package for reading user input in console.

Here is the some good points compared with other/similar packages. It can handle SIGINT (Ctrl+C) while reading input and returns error. It allows to change IO interface as io.Writer and io.Reader so it's easy to test of your go program with this package (This package is also well-tested!). It also supports raw mode input (reading input without prompting) for multiple platform (Darwin, Linux and Windows). Not only this it allows to prompt complex input via Option struct.

The documentation is on GoDoc.


Use go get to install this package:

$ go get


The following is the simple example,

ui := &input.UI{
    Writer: os.Stdout,
    Reader: os.Stdin,

query := "What is your name?"
name, err := ui.Ask(query, &input.Options{
    Default: "tcnksm",
    Required: true,
    Loop:     true,

You can check other examples in here.


  1. Fork (
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create new Pull Request


Taichi Nakashima

You can’t perform that action at this time.