当前位置: 首页>>代码示例>>Golang>>正文


Golang Color.Set方法代码示例

本文整理汇总了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

	}
}
开发者ID:bcicen,项目名称:crane,代码行数:35,代码来源:containers.go

示例2: boldLine

// Print a thick line break (of '=' characters).
func boldLine(c *color.Color) {
	c.Set()
	defer colorUnset()
	lineBreak("=")
}
开发者ID:GreenRaccoon23,项目名称:lss-img,代码行数:6,代码来源:display.go

示例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...)
}
开发者ID:thenativeweb,项目名称:buntstift-go,代码行数:5,代码来源:buntstift.go

示例4: line

// Print a thin line break (of '-' characters).
func line(c *color.Color) {
	c.Set()
	defer colorUnset()
	lineBreak("-")
}
开发者ID:GreenRaccoon23,项目名称:lss-img,代码行数:6,代码来源:display.go


注:本文中的github.com/fatih/color.Color.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。