-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.go
More file actions
41 lines (35 loc) · 764 Bytes
/
utils.go
File metadata and controls
41 lines (35 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"bufio"
"fmt"
"os"
"strings"
"github.com/spf13/viper"
)
func getPublicKey () string {
publicKey := viper.GetString("key.public")
if publicKey == "" {
fmt.Println("key not set")
return ""
}
return publicKey
}
func padString (input string, length int) string {
if len(input) >= length {
return input
}
return input + " " + strings.Repeat(" ", length-len(input)-1)
}
func getUserInput (prompt string) string {
fmt.Print(prompt)
reader := bufio.NewReader(os.Stdin)
input, _ := reader.ReadString('\n')
return strings.TrimSpace(input)
}
func truncateString (s string) string {
//l := 40
//if len(s) > l {
// return s[:l-3] + "..."
//}
return s
}