• Stars
    star
    1,679
  • Rank 27,815 (Top 0.6 %)
  • Language
    Go
  • License
    MIT License
  • Created about 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Colored pretty printer for Go language

pp Go Go Reference

Colored pretty printer for Go language

Usage

Just call pp.Print().

import "github.com/k0kubun/pp/v3"

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()

See the documentation for API details.

Configuration

They can be customized globally with pp.Default.

pp.Default.SetColoringEnabled(false)
pp.Println() // no color

You can also create individual instances that do not interfere with the default printer:

mypp := pp.New()
mypp.SetColoringEnabled(false)
mypp.SetExportedOnly(true)
mypp.Println()

See PrettyPrinter documentation for all available configurations.

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.Default.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

More Repositories

1

hamlit

High Performance Haml Implementation
Ruby
979
star
2

md2key

Convert markdown to keynote
Ruby
977
star
3

xremap

Key remapper for X11 and Wayland
Rust
770
star
4

Nocturn

Multi-platform Twitter Client built with React, Redux and Electron
JavaScript
714
star
5

gitstar-ranking

GitHub star ranking for users, organizations and repositories
Kotlin
700
star
6

llrb

LLVM-based JIT Compiler for Ruby
C
303
star
7

rack-user_agent

Rack::Request extension for handling User-Agent
Ruby
187
star
8

activerecord-precount

N+1 count query killer for ActiveRecord
Ruby
154
star
9

activerecord-precounter

Yet Another N+1 COUNT Query Killer for ActiveRecord
Ruby
102
star
10

go-ansi

Windows-portable ANSI escape sequence utility for Go language
Go
85
star
11

tetris

TETRIS for your terminal
Go
76
star
12

yarv-mjit

MRI method JIT compiler based on original stack-based YARV instructions (Development Repository of ruby/ruby#1782, already merged)
Ruby
65
star
13

itamae-plugin-recipe-rbenv

Itamae/MItamae plugin to install ruby with rbenv
Ruby
56
star
14

jjvm

JVM implementation written in Java
Java
53
star
15

karabiner-ruby

Lightweight keyremap configuration DSL for Karabiner
Ruby
53
star
16

ruby-jit-challenge

Tutorial to write a Ruby JIT
Ruby
51
star
17

itamae-go

Go implementation of itamae embedding mruby
Go
50
star
18

dotfiles

Bootstrap development environment
Shell
49
star
19

hescape

C library for fast HTML escape using SSE instructions
C
48
star
20

railsbench

Rails 6.1 version of headius/pgrailsbench with database seeds
Ruby
43
star
21

gem-default

Change a non-default gem to a default gem in your local environment
Ruby
37
star
22

rebuild

Development environment bootstrap automation toolkit for OSX
Ruby
31
star
23

vim-open-github

Quickly open your current buffer in GitHub.
Ruby
29
star
24

graphql-query-builder

GraphQL query builder for Java
Java
23
star
25

perf-profile

Profiling C code with Linux perf made easy
Python
19
star
26

wrap-bootstrap-rails

Rails plugin generator for Wrap Bootstrap design templates
Ruby
18
star
27

gosick

Scheme implementation by Go language
Go
18
star
28

hescape-ruby

HTML escape utility for Ruby
Ruby
17
star
29

twitter-auth

Twitter access token generator for CLI
Go
14
star
30

fluent-logger-go

A structured logger for Fluentd in Golang
Go
13
star
31

thunderbolt

Twitter client using Streaming API in Go language
Go
13
star
32

lineprof

Easy-to-use line profiler for Ruby
Ruby
13
star
33

itamae-template

Itamae template generator for roles and cookbooks
Ruby
11
star
34

stackflame

Stackflame provides a simple API to deal with Flamegraph of stackprof
Ruby
9
star
35

itamae-plugin-recipe-docker

Itamae recipe to install docker
Ruby
9
star
36

ghq-cache

Show frequently used repositories first in ghq list
Ruby
9
star
37

github_api-v4-client

A very thin GitHub GraphQL API v4 client
Ruby
7
star
38

clannad

C language compiler
C
7
star
39

go-keybind

Multi-platform terminal key input reader for Go language
Go
7
star
40

action-slack

Notify Slack with incoming webhook for GitHub Actions
TypeScript
6
star
41

tomodachi

Automatic follow back tool with Twitter streaming API
Ruby
5
star
42

twitter

Tiny twitter client library for Go language
Go
5
star
43

dwarftree

A wrapper of objdump --dwarf=info to visualize an object's structure and show code size
Ruby
5
star
44

yjit

Enable YJIT
Ruby
5
star
45

rack-stackprof

Periodically dump StackProf profile result to `tmp` with easy-to-understand filenames
Ruby
4
star
46

go-termios

Go bindings for termios
Go
4
star
47

legacy-dotfiles

Configuration for my client machines
Common Lisp
4
star
48

misc

Miscellaneous scripts and stuff
JavaScript
4
star
49

github-stream

GitHub Events API v3 client for Go language
Go
3
star
50

ajax_render

Rails plugin to simplify your ajax implementation
Ruby
3
star
51

isucon4-qualifier

My answer for ISUCON4 qualifier
Go
3
star
52

sandal

Fault-aware model checker for message passing systems
Go
3
star
53

rockstar

Colorful GitHub user summarizer
Go
3
star
54

mitamae-plugin-resource-deploy_directory

Fork of mitamae-plugin-resource-deploy_revision to deploy directory instead of git repository
Ruby
3
star
55

perf

Use Linux perf for some region of Ruby code easily
Ruby
3
star
56

itamae-plugin-resource-ghq

Itamae resource plugin to manage repositories with ghq
Ruby
3
star
57

itamae-plugin-resource-cask

Itamae resource plugin for homebrew cask
Ruby
2
star
58

chrome-response-time

Chrome extension to show response time on badge
JavaScript
2
star
59

ruby-color

ruby-color foo.rb
Ruby
2
star
60

mitamae-plugin-resource-cron

MItamae plugin to reproduce the behavior of cron resource in Chef
Ruby
2
star
61

sigcdump

Sigdump for C backtrace
Ruby
2
star
62

ruboty

My Ruboty configuration
Ruby
2
star
63

libx11-ruby

Ruby binding of libx11 mostly for xlib
Ruby
2
star
64

xraise

Fast X Window Raiser
Rust
2
star
65

userstream

Twitter UserStream client with OAuth for Go language
Go
2
star
66

mjit-disable

Unofficial gem to disable MJIT dynamically
Ruby
1
star
67

itamae-sandbox

Ruby
1
star
68

PKGBUILDs

PKGBUILDs for Arch Linux
Shell
1
star
69

picturesque

Personal web server for image distribution
Go
1
star
70

changelogger

Local file change logger
Go
1
star
71

ruby-prehistory

A repository generated by https://github.com/yhara/ruby-prehistory
C
1
star
72

ruby-cvs

cvs2git from https://github.com/takahashim/rhg-repository
C
1
star
73

isucon2-ruby

My answer for ISUCON2
Ruby
1
star
74

mitamae-plugin-recipe-rvm

MItamae plugin similar to sous-chefs/rvm
Ruby
1
star
75

GomokuAI

Artificial Intelligence for Gomoku
C++
1
star
76

ruboty-ghibli

A Ruboty plugin
Ruby
1
star
77

mitamae-plugin-recipe-buildpack

MItamae plugin to run heroku-buildpack
Ruby
1
star
78

submarine

Ruby
1
star
79

erb-trim

An ERB extension that supports <%-=
Ruby
1
star
80

erb-indent

ERB with de-indentation
Ruby
1
star
81

vagrant-box-arch

Arch Linux Vagrant box for VirtualBox provider
1
star
82

lambda-gyazo-s3

Gyazo server clone implemented with AWS Lambda and API Gateway
Java
1
star
83

each_with_rank

Rank iterator for Enumerable
Ruby
1
star
84

pr_viewer

Pull requests viewer
Go
1
star