pp

Colored pretty printer for Go language

  • 所有者: k0kubun/pp
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

pp wercker status

Colored pretty printer for Go language

Usage

Just call pp.Print().

import "github.com/k0kubun/pp"

m := map[string]string{"foo": "bar", "hello": "world"}
pp.Print(m)

API

fmt package-like functions are provided.

pp.Print()
pp.Println()
pp.Sprint()
pp.Fprintf()
// ...

You can also create own instances that do not interfer with the default printer

mypp := pp.New()
mypp.SetOutput(os.Stderr)
mypp.Println()
// ...

API doc is available at: http://godoc.org/github.com/k0kubun/pp

Custom colors

If you require, you may change the colors (all or some) for syntax highlighting:

// Create a struct describing your scheme
scheme := pp.ColorScheme{
	Integer:       pp.Green, pp.Bold,
	Float:         pp.Black, pp.BackgroundWhite, pp.Bold,
	String:        pp.Yellow,
}

// Register it for usage
pp.SetColorScheme(scheme)

Look into ColorScheme struct for the field names.

If you would like to revert to the default highlighting, you may do so by calling pp.ResetColorScheme().

Out of the following color flags, you may combine any color with a background color and optionally with the bold parameter. Please note that bold will likely not work on the windows platform.

// Colors
Black
Red
Green
Yellow
Blue
Magenta
Cyan
White

// Background colors
BackgroundBlack
BackgroundRed
BackgroundGreen
BackgroundYellow
BackgroundBlue
BackgroundMagenta
BackgroundCyan
BackgroundWhite

// Other
Bold

// Special
NoColor

Demo

Timeline

UserStream event

Works on windows

License

MIT License

主要指标

概览
名称与所有者k0kubun/pp
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2014-12-01 14:15:31
推送于2025-06-01 23:39:32
最后一次提交2025-05-26 06:37:19
发布数27
最新版本名称v3.4.1 (发布于 )
第一版名称v0.0.1 (发布于 )
用户参与
星数1.9k
关注者数19
派生数105
提交数227
已启用问题?
问题数0
打开的问题数0
拉请求数52
打开的拉请求数1
关闭的拉请求数11
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?