Last active
January 1, 2016 21:39
-
-
Save agtorre/8204847 to your computer and use it in GitHub Desktop.
colorize example
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/agtorre/gocolorize" | |
"github.com/agtorre/gocolorize/paints" | |
) | |
func main() { | |
//stateful | |
c := gocolorize.Colorize{FgColor: gocolorize.FgRed, BgColor: gocolorize.BgWhite} | |
result := c.Paint("This", "will", "be colored, it can also accepts numbers:", 1, "and complex types") | |
fmt.Println(result) | |
var s := c.PaintString("this can also return a string rather than a Colorize{}") | |
//stateless chaining, this is pretty inefficient, but not terrible for a one-off | |
fmt.Println(paints.PaintRed(paints.PaintBgWhite("This", "will", "be colored the same color"))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment