mirror of
https://github.com/rwinkhart/go-boilerplate.git
synced 2026-09-06 09:07:15 -04:00
Rename integer input function to clarify it is capable of returning negative values
This commit is contained in:
+3
-3
@@ -36,9 +36,9 @@ func InputBinary(prompt string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// InputPositiveInt prompts the user for input and returns the input as an integer.
|
// InputInt prompts the user for input and returns the input as an integer.
|
||||||
// A negative min/max value will disable the respective limit.
|
// A negative min/max value will disable the respective limit.
|
||||||
func InputPositiveInt(prompt string, min, max int) int {
|
func InputInt(prompt string, min, max int) int {
|
||||||
for {
|
for {
|
||||||
fmt.Print("\n" + prompt + " ")
|
fmt.Print("\n" + prompt + " ")
|
||||||
var userInput int
|
var userInput int
|
||||||
@@ -54,5 +54,5 @@ func InputMenuGen(prompt string, options []string) int {
|
|||||||
for i, option := range options {
|
for i, option := range options {
|
||||||
fmt.Printf("%d. %s\n", i+1, option)
|
fmt.Printf("%d. %s\n", i+1, option)
|
||||||
}
|
}
|
||||||
return InputPositiveInt(prompt, 1, len(options))
|
return InputInt(prompt, 1, len(options))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user