Skip to content

Commit b4c44a4

Browse files
suwakeindeloof
authored andcommitted
Eliminate magic number in init functions
Signed-off-by: keitosuwahara <[email protected]>
1 parent fb5a864 commit b4c44a4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cmd/formatter/colors.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ const (
5959
Auto = "auto"
6060
)
6161

62+
// ansiColorOffset is the offset for basic foreground colors in ANSI escape codes.
63+
const ansiColorOffset = 30
64+
6265
// SetANSIMode configure formatter for colored output on ANSI-compliant console
6366
func SetANSIMode(streams command.Streams, ansi string) {
6467
if !useAnsi(streams, ansi) {
@@ -127,8 +130,8 @@ func rainbowColor() colorFunc {
127130
func init() {
128131
colors := map[string]colorFunc{}
129132
for i, name := range names {
130-
colors[name] = makeColorFunc(strconv.Itoa(30 + i))
131-
colors["intense_"+name] = makeColorFunc(strconv.Itoa(30+i) + ";1")
133+
colors[name] = makeColorFunc(strconv.Itoa(ansiColorOffset + i))
134+
colors["intense_"+name] = makeColorFunc(strconv.Itoa(ansiColorOffset+i) + ";1")
132135
}
133136
rainbow = []colorFunc{
134137
colors["cyan"],

0 commit comments

Comments
 (0)