本文整理汇总了Golang中github.com/agtorre/gocolorize.Colorize类的典型用法代码示例。如果您正苦于以下问题:Golang Colorize类的具体用法?Golang Colorize怎么用?Golang Colorize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Colorize类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getColorByte
func (l *loggingT) getColorByte(s severity, b []byte) []byte {
var c gocolorize.Colorize
switch s {
case warningLog:
c = gocolorize.NewColor("yellow")
case errorLog:
c = gocolorize.NewColor("red")
case fatalLog:
c = gocolorize.NewColor("magenta")
default:
c = gocolorize.NewColor("green")
}
return []byte(c.Paint(string(b)))
}
开发者ID:rshmelev,项目名称:glog,代码行数:14,代码来源:glog.go
示例2: main
func main() {
// one way to define a stateful colorizer
var green gocolorize.Colorize
green.SetColor(gocolorize.Green)
g := green.Paint
// Another way to do it
red := gocolorize.Colorize{Fg: gocolorize.Red}
r := red.Paint
// now with string construction
green_black := gocolorize.Colorize{Fg: gocolorize.Blue}
// toggle attributes
green_black.ToggleUnderline()
b := green_black.Paint
//all in 1 line
c := gocolorize.NewColor("yellow:black").Paint
//r := gocolorize.COLOR_RED
fmt.Println(b("On the twelfth day of Christmas"))
fmt.Println(b("my true love sent to me:"))
fmt.Println(g("Twelve"), c("Drummers"), r("Drumming"))
fmt.Println(g("Eleven"), c("Pipers"), r("Piping"))
fmt.Println(g("Ten"), c("Lords"), r("a Leaping"))
fmt.Println(g("Nine"), c("Ladies"), r("Dancing"))
fmt.Println(g("Eight"), c("Maids"), r("a Milking"))
fmt.Println(g("Seven"), c("Swans"), r("a Swimming"))
fmt.Println(g("Six"), c("Geese"), r("a Laying"))
fmt.Println(g("Five"), c("Golden"), r("Rings"))
fmt.Println(g("Four"), c("Calling"), r("Birds"))
fmt.Println(g("Three"), c("French"), r("Hens"))
fmt.Println(g("Two"), c("Turtle"), r("Doves"))
fmt.Println(b("and a Partridge in a Pear Tree"))
}
开发者ID:pondyond,项目名称:leanote-all,代码行数:37,代码来源:song.go
示例3: ColorSuccess
func ColorSuccess(message string) string {
success := gocolorize.Colorize{Fg: gocolorize.Green}
return success.Paint(message)
}
开发者ID:hoop33,项目名称:elasticprompt,代码行数:4,代码来源:logger.go
示例4: ColorError
func ColorError(message string) string {
err := gocolorize.Colorize{Fg: gocolorize.Red}
err.ToggleBold()
return err.Paint(message)
}
开发者ID:hoop33,项目名称:elasticprompt,代码行数:5,代码来源:logger.go
示例5: ColorWarning
func ColorWarning(message string) string {
warning := gocolorize.Colorize{Fg: gocolorize.Yellow}
return warning.Paint(message)
}
开发者ID:hoop33,项目名称:elasticprompt,代码行数:4,代码来源:logger.go
示例6: ColorInfo
func ColorInfo(message string) string {
info := gocolorize.Colorize{Fg: gocolorize.Magenta}
return info.Paint(message)
}
开发者ID:hoop33,项目名称:elasticprompt,代码行数:4,代码来源:logger.go
示例7: newColorLogger
func newColorLogger(out io.Writer, severity string, color gocolorize.Color) *log.Logger {
c := gocolorize.Colorize{Fg: color}
return log.New(out, c.Paint("severity:"+severity)+"\t", log.Ldate|log.Ltime|log.Lshortfile)
}
开发者ID:narita-takeru,项目名称:aws-sdk-go-wrapper,代码行数:4,代码来源:default.go
注:本文中的github.com/agtorre/gocolorize.Colorize类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论