-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.go
More file actions
49 lines (43 loc) · 684 Bytes
/
Copy pathutils.go
File metadata and controls
49 lines (43 loc) · 684 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
42
43
44
45
46
47
48
49
package main
import (
"fmt"
"time"
)
type Colors struct {
Aqua int
Green int
Blue int
Purple int
Pink int
Gold int
Orange int
Red int
Gray int
}
var colors = Colors{
Aqua: 0x1abc9c,
Green: 0x57f287,
Blue: 0x3498db,
Purple: 0x9b59b6,
Pink: 0xe91e63,
Gold: 0xf1c40f,
Orange: 0x367322,
Red: 0xed4245,
Gray: 0x95a5a6,
}
func Truncate(s string, max int) string {
if len(s) > max {
return s[0:max-3] + "..."
}
return s
}
func Ternary[T any](a bool, b T, c T) T {
if a {
return b
}
return c
}
func Timestamp(t string) string {
timestamp, _ := time.Parse(time.RFC3339Nano, t)
return fmt.Sprintf("<t:%d:R>", timestamp.Unix())
}