Debian Codegraph @

pkg/color/util.go

raw
1 package color
2
3 import (
4 "fmt"
5 "os"
6 "strings"
7 )
8
9 func boolPtr(v bool) *bool {
10 return &v
11 }
12
13 // noColorIsSet returns true if the NO_COLOR environment variable is set (regardless of value).
14 // This follows the NO_COLOR standard (https://no-color.org/) where the presence
15 // of the environment variable, with any value including empty, should disable colors.
16 func noColorIsSet() bool {
17 _, exists := os.LookupEnv("NO_COLOR")
18
19 return exists
20 }
21
22 // sprintln is a helper function to format a string with fmt.Sprintln and trim the trailing newline.
23 func sprintln(a ...any) string {
24 return strings.TrimSuffix(fmt.Sprintln(a...), "\n")
25 }