color

package
v0.0.13-0...-246b94f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FgBlack 黑色
	FgBlack attr = iota + 30
	// FgRed 红色
	FgRed
	// FgGreen 绿色
	FgGreen
	// FgYellow 黄色
	FgYellow
	// FgBlue 蓝色
	FgBlue
	// FgMagenta 品红
	FgMagenta
	// FgCyan 青色
	FgCyan
	// FgWhite 白色
	FgWhite
)
View Source
const (
	// Purple 紫色
	Purple = 35
	// Blue 蓝色
	Blue = 34
)

Variables

View Source
var (
	// NoColor 关闭颜色开关 本行代码来自github.com/fatih/color, 感谢fatih的付出
	NoColor = os.Getenv("TERM") == "dumb" ||
		(!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()))
)

Functions

This section is empty.

Types

type BodyType

type BodyType int

BodyType 区分body的类型

const (
	// JSONType http body是json类型的
	JSONType BodyType = iota + 1
	// XMLType http body是xml类型的
	XMLType
	// YAMLType http body是yaml类型的
	YAMLType
	// TxtType http body是txt类型的
	TxtType
)

type Color

type Color struct {
	// contains filtered or unexported fields
}

Color 着色核心数据结构

func New

func New(openColor bool, c ...attr) *Color

New 着色模块构造函数

func (*Color) Sbluef

func (c *Color) Sbluef(format string, a ...interface{}) string

Sbluef 蓝色函数

func (*Color) Spurple

func (c *Color) Spurple(a ...interface{}) string

Spurple 紫色函数

func (*Color) Spurplef

func (c *Color) Spurplef(format string, a ...interface{}) string

Spurplef 紫色函数

type Formatter

type Formatter struct {
	KeyColor        *Color // 设置key的颜色
	StringColor     *Color // 设置string的颜色
	BoolColor       *Color // 设置bool的颜色
	NumberColor     *Color // 设置数字的颜色
	NullColor       *Color // 设置null的颜色
	StringMaxLength int
	Indent          int
	DisabledColor   bool
	RawStrings      bool
	// contains filtered or unexported fields
}

Formatter 是颜色高亮核心结构体

func NewFormatEncoder

func NewFormatEncoder(r io.Reader, openColor bool, bodyType BodyType) *Formatter

NewFormatEncoder 着色json/yaml/xml构造函数

func (*Formatter) Marshal

func (f *Formatter) Marshal(jsonObj interface{}) ([]byte, error)

Marshal 给原始的结构化数据着色

func (*Formatter) Read

func (f *Formatter) Read(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL