Skip to content

Instantly share code, notes, and snippets.

@agtorre
Last active January 1, 2016 21:39
Show Gist options
  • Save agtorre/8204847 to your computer and use it in GitHub Desktop.
Save agtorre/8204847 to your computer and use it in GitHub Desktop.
colorize example
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