init commit
This commit is contained in:
commit
4ff821beed
8 files changed
+678
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Ask(str string) bool {
|
||||
var input string
|
||||
fmt.Printf("-> %s (Y/n): ", str)
|
||||
fmt.Scanln(&input)
|
||||
input = strings.TrimSpace(input)
|
||||
input = strings.ToLower(input)
|
||||
if input != "y" && input != "" && input != "yes" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func ToString(v interface{}) string {
|
||||
switch val := v.(type) {
|
||||
case int:
|
||||
return strconv.Itoa(val)
|
||||
case float64:
|
||||
return strconv.FormatFloat(val, 'f', -1, 64)
|
||||
case string:
|
||||
return val
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user