summaryrefslogtreecommitdiff
path: root/helpers/helpers.go
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/helpers.go')
-rw-r--r--helpers/helpers.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/helpers/helpers.go b/helpers/helpers.go
new file mode 100644
index 0000000..ac92e6a
--- /dev/null
+++ b/helpers/helpers.go
@@ -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 ""
+ }
+}