-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathcolor.go
More file actions
113 lines (90 loc) · 1.92 KB
/
color.go
File metadata and controls
113 lines (90 loc) · 1.92 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
// 🤖 GitHub Repository: https://github.com/gofiber/fiber
// 📌 API Documentation: https://docs.gofiber.io
package fiber
// Colors is a struct to define custom colors for Fiber app and middlewares.
type Colors struct {
// Black color.
//
// Optional. Default: "\u001b[90m"
Black string
// Red color.
//
// Optional. Default: "\u001b[91m"
Red string
// Green color.
//
// Optional. Default: "\u001b[92m"
Green string
// Yellow color.
//
// Optional. Default: "\u001b[93m"
Yellow string
// Blue color.
//
// Optional. Default: "\u001b[94m"
Blue string
// Magenta color.
//
// Optional. Default: "\u001b[95m"
Magenta string
// Cyan color.
//
// Optional. Default: "\u001b[96m"
Cyan string
// White color.
//
// Optional. Default: "\u001b[97m"
White string
// Reset color.
//
// Optional. Default: "\u001b[0m"
Reset string
}
// DefaultColors Default color codes
var DefaultColors = Colors{
Black: "\u001b[90m",
Red: "\u001b[91m",
Green: "\u001b[92m",
Yellow: "\u001b[93m",
Blue: "\u001b[94m",
Magenta: "\u001b[95m",
Cyan: "\u001b[96m",
White: "\u001b[97m",
Reset: "\u001b[0m",
}
// defaultColors is a function to override default colors to config
func defaultColors(colors *Colors) Colors {
if colors == nil {
return DefaultColors
}
cfg := *colors
if cfg.Black == "" {
cfg.Black = DefaultColors.Black
}
if cfg.Red == "" {
cfg.Red = DefaultColors.Red
}
if cfg.Green == "" {
cfg.Green = DefaultColors.Green
}
if cfg.Yellow == "" {
cfg.Yellow = DefaultColors.Yellow
}
if cfg.Blue == "" {
cfg.Blue = DefaultColors.Blue
}
if cfg.Magenta == "" {
cfg.Magenta = DefaultColors.Magenta
}
if cfg.Cyan == "" {
cfg.Cyan = DefaultColors.Cyan
}
if cfg.White == "" {
cfg.White = DefaultColors.White
}
if cfg.Reset == "" {
cfg.Reset = DefaultColors.Reset
}
return cfg
}