basic.go
func (ui *BasicUI) Ask(message, trim string) (string, error) {
	if message != "" {
		ui.Output(message)
	}
	reader := bufio.NewReader(ui.Reader)
	res, err := reader.ReadString('\n')
	if err != nil {
		return "", err
	}
	res = strings.Replace(res, "\r", "", -1) //this will only be useful under windows
	res = strings.Replace(res, "\n", "", -1)
	res = strings.Trim(res, trim)
	return res, err
}
func (ui *BasicUI) Ask(message, trim string) (string, error) {
	if message != "" {
		ui.Output(message)
	}
	reader := bufio.NewReader(ui.Reader)
	res, err := reader.ReadString('\n')
	if err != nil {
		return "", err
	}
	res = strings.Replace(res, "\r", "", -1) //this will only be useful under windows
	res = strings.Replace(res, "\n", "", -1)
	res = strings.Trim(res, trim)
	return res, err
}
func ( ui * BasicUI ) Ask ( message , trim string ) ( string , error ) { if message != " " { ui . Output ( message ) } reader := bufio . NewReader ( ui . Reader ) res , err := reader . ReadString ( '\n' ) if err != nil { return " " , err } res = strings . Replace ( res , " \r " , " " , - 1 ) //this will only be useful under windows res = strings . Replace ( res , " \n " , " " , - 1 ) res = strings . Trim ( res , trim ) return res , err }
//Ask will call output with message then wait for Reader to print newline (\n).
//If Reader is os.Stdin then that is when ever a user presses [enter].
//It will clean the response by removing any carriage returns and new lines that if finds.
//Then it will trim the message using the trim variable.
//Use and empty string to specify you do not want to trim.
//If a message is not used ("") then it will not prompt user before waiting on a response.
Ask will call output with message then wait for Reader to print newline ( \ n ) . If Reader is os . Stdin then that is when ever a user presses [ enter ] . It will clean the response by removing any carriage returns and new lines that if finds . Then it will trim the message using the trim variable . Use and empty string to specify you do not want to trim . If a message is not used ( ) then it will not prompt user before waiting on a response .