Exemplo n.º 1
0
func loop() {
	for {
		switch result := readline.ReadLine(&prompt); true {
		case result == nil:
			println()
			return
		case *result != "": //ignore blank lines
			parseCommand(*result)
			readline.AddHistory(*result) //allow user to recall this line
		}
	}
}
Exemplo n.º 2
0
func main() {
	prompt := "> "
	//loop until ReadLine returns nil (signalling EOF)
L:
	for {
		switch result := readline.ReadLine(&prompt); true {
		case result == nil:
			println()
			break L //exit loop
		case *result != "": //ignore blank lines
			println(*result)
			readline.AddHistory(*result) //allow user to recall this line
		}
	}
}