How do I print color out in to my console in Go? I don't want to use any libraries I'm trying learn how the coloring works. I've adding "\033[33m" in front of my string still no color.
How do I print color out in to my console in Go? I don't want to use any libraries I'm trying learn how the coloring works. I've adding "\033[33m" in front of my string still no color.
What you can do is study the source code of this library as suggested out by @jub0bs already. It is pretty easy to follow.
This code prints hello in blue.
I got 34 from here and Sprintf from here
package main
import (
"fmt"
)
func main() {
colored := fmt.Sprintf("\x1b[%dm%s\x1b[0m", 34, "Hello")
fmt.Println(colored)
}