Last active
August 7, 2020 04:49
-
-
Save kemokemo/b679591791c9e79ce47d60270e09a879 to your computer and use it in GitHub Desktop.
A golang sample with colored terminal output. Cross-platform support, of course.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/fatih/color" | |
"github.com/mattn/go-colorable" | |
) | |
var out = colorable.NewColorableStdout() | |
func main() { | |
fmt.Println("hoge normal color") | |
iColor := color.New(color.FgHiGreen) | |
fI := iColor.FprintFunc() | |
fI(out, "hoge green color\n") | |
wColor := color.New(color.FgHiYellow) | |
fW := wColor.FprintFunc() | |
fW(out, "hoge yellow color\n") | |
eColor := color.New(color.FgHiRed) | |
fE := eColor.FprintFunc() | |
fE(out, "hoge red color\n") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
git clone https://gist.github.com/kemokemo/b679591791c9e79ce47d60270e09a879 colored-out cd colored-out go run colored-out.go