Skip to content

Instantly share code, notes, and snippets.

@bfu4
Created August 20, 2021 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bfu4/e28611cd058b0c33726854cc9ca6a69b to your computer and use it in GitHub Desktop.
Save bfu4/e28611cd058b0c33726854cc9ca6a69b to your computer and use it in GitHub Desktop.
colors again
package colors
import "strconv"
type Color int
const (
Black Color = iota
Red
Green
Yellow
Blue
Magenta
Turquoise
LightGray
Gray
BrightRed
BrightGreen
BrightYellow
BrightBlue
BrightMagenta
Aqua
White
LightRed Color = 124
LightOrange Color = 214
LightYellow Color = 226
LightGreen Color = 82
LightBlue Color = 63
LightPurple Color = 183
LightPink Color = 212
formatSequence = "\u001b[38;5;"
resetSequence = "\033[0m"
rowJump = 36
)
func Custom(initial, shift int) Color {
return Color(initial + (rowJump * shift))
}
func (c Color) String() string {
return formatSequence + strconv.Itoa(int(c)) + "m"
}
func (c Color) Text(text string) string {
return c.String() + text + resetSequence
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment