本文整理汇总了Golang中github.com/fatih/color.Color.Set方法的典型用法代码示例。如果您正苦于以下问题:Golang Color.Set方法的具体用法?Golang Color.Set怎么用?Golang Color.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/fatih/color.Color
的用法示例。
在下文中一共展示了Color.Set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: write
// returns a function that will format and writes the line extracted from the logs of a given container
func write(prefix string, color *ansi.Color, timestamps bool) func(dest io.Writer, token []byte) (n int, err error) {
return func(dest io.Writer, token []byte) (n int, err error) {
countingWriter := countingWriter{Writer: dest}
if color != nil {
ansi.Output = &countingWriter
color.Set()
}
_, err = countingWriter.Write([]byte(prefix))
if err == nil {
if !timestamps {
// timestamps are always present in the incoming stream for
// sorting purposes, so we strip them if the user didn't ask
// for them
const timestampPrefixLength = 31
strip := timestampPrefixLength
if string(token[0]) == "[" {
// it seems that timestamps are wrapped in [] for events
// streamed in real time during a `docker logs -f`
strip = strip + 2
}
token = token[strip:]
}
_, err = countingWriter.Write(token)
}
if err == nil {
if color != nil {
ansi.Unset()
}
_, err = dest.Write([]byte("\n"))
}
return countingWriter.written, err
}
}
示例2: boldLine
// Print a thick line break (of '=' characters).
func boldLine(c *color.Color) {
c.Set()
defer colorUnset()
lineBreak("=")
}
示例3: printf
func (b *Buntstift) printf(Color *color.Color, format string, a ...interface{}) (n int, err error) {
Color.Set()
defer b.unsetColor()
return fmt.Fprintf(Output, format, a...)
}
示例4: line
// Print a thin line break (of '-' characters).
func line(c *color.Color) {
c.Set()
defer colorUnset()
lineBreak("-")
}