25 lines
292 B
Go
25 lines
292 B
Go
package prompt
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func StringPrompt(label string) string {
|
|
var str string
|
|
|
|
r := bufio.NewReader(os.Stdin)
|
|
|
|
for {
|
|
fmt.Fprint(os.Stderr, label+" ")
|
|
|
|
str, _ = r.ReadString('\n')
|
|
if str != "" {
|
|
break
|
|
}
|
|
}
|
|
|
|
return strings.TrimSpace(str)
|
|
}
|