-
Notifications
You must be signed in to change notification settings - Fork 0
/
libfle.go
37 lines (29 loc) · 963 Bytes
/
libfle.go
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
package libfle
import (
"math/rand"
"strings"
"github.com/fatih/color"
)
func getfles() []func(string) string {
return []func(string) string{
func(d string) string { return color.New(color.FgYellow).SprintFunc()(d) },
func(d string) string { return color.New(color.FgBlue).SprintFunc()(d) },
func(d string) string { return color.New(color.FgRed).SprintFunc()(d) },
func(d string) string { return color.New(color.FgYellow).SprintFunc()(d) },
func(d string) string { return color.New(color.FgMagenta).SprintFunc()(d) },
func(d string) string { return color.New(color.FgCyan).SprintFunc()(d) },
func(d string) string { return color.New(color.FgWhite).SprintFunc()(d) },
}
}
func stringtoslice(s string) []string {
return strings.Split(s, "")
}
func NewFle(tofle string) string {
flist := getfles()
s := stringtoslice(tofle)
result := ""
for i := 0; i < len(s); i++ {
result += flist[rand.Intn(len(flist))](s[i])
}
return result
}