Comments (9)
If we stop deprecating
pp.ColoringEnabled = false
, would you use it?
As to this problem, now there's an officially blessed API: https://github.com/k0kubun/pp/releases/tag/v3.2.0
from pp.
Looks great, thanks!
Sorry I never followed up on the original request. @KEINOS is correct about what I was asking for, and I bet that dd
would have been best for me at the time. I had been using pp
for other purposes and came on a new case where I didn't want color (for logging, which needed to be readable when logged to file.)
from pp.
As to this problem, now there's an officially blessed API: https://github.com/k0kubun/pp/releases/tag/v3.2.0
Wow!
package main
import (
"fmt"
"github.com/Code-Hex/dd"
"github.com/k0kubun/pp/v3"
)
func main() {
sample := []string{
"foo",
"bar",
}
// pp
{
pp.Default.SetColoringEnabled(false)
pp.Println(sample)
}
// dd
{
fmt.Println(dd.Dump(sample))
}
// Output:
//
// []string{
// "foo",
// "bar",
// }
// []string{
// "foo",
// "bar",
// }
}
- View it online @ Go Playground
For my purposes this is simple and sufficient. How about you @jlearman?
@k0kubun Thank you very much! From now on, I will stick to pp
😉
from pp.
Same as #66 (comment), please show us an example code you want to use. Otherwise, this issue is not actionable for anybody besides you.
from pp.
Let's reopen this after your further clarification.
from pp.
@jlearman You mean something like below, don't you?
package main
import (
"fmt"
"github.com/Code-Hex/dd"
"github.com/k0kubun/pp/v3"
)
func main() {
sample := []string{
"foo",
"bar",
}
pp.Println(sample)
fmt.Println(dd.Dump(sample))
}
// Output:
// []�[32mstring�[0m{
// �[31m�[1m"�[0m�[31mfoo�[0m�[31m�[1m"�[0m,
// �[31m�[1m"�[0m�[31mbar�[0m�[31m�[1m"�[0m,
// }
// []string{
// "foo",
// "bar",
// }
- View it online @ Go Playground
As described in the repository description, the pp
package is dedicated to color text printing prettily. Therefore, for CUI purposes, pp
is nice and simple.
However, when used as a dump in print-debug or GoPlayground, I recommend to use dd instead. I use them both though.
from pp.
when used as a dump in print-debug
Any problem in pp for print debugging? It's the primary purpose of this library.
from pp.
@k0kubun
Any problem in pp for print debugging?
No. Not at all.
But the issue is "a simple way to disable all color". And the answer seemed a bit mean to me, so I wanted to provoke and ask what kind of use cases @jlearman had in mind. That's why I posted "an example code that we want to use" as you mentioned. That's all. 😉
Even though pp
is great and nice for printing debug-infos "in color", I believe there's no function that prints with no-color, out of the box. Such like dd.Dump
does.
... ... or does it?
from pp.
If we stop deprecating pp.ColoringEnabled = false
, would you use it?
If it doesn't work, WDYT about each of the following options?
pp.WithColor(false).Println(...)
p.Println(...)
(k0kubun/pp/p
will be a package for non-colored output)pp.Println(...)
does not colorize outputs when the destination IO is not TTY (Sprint*
should be kept colored, or just check stdout for convenience?)
from pp.
Related Issues (20)
- go mod doesn't install 3.0.2 HOT 1
- Feature request: Pretty print big.Int and big.Float? HOT 5
- Feature request: Add `pp:"noprint"` tag HOT 1
- Bug: `printTime` assumes the standard library time
- The color part of vim is messy HOT 7
- Option for thousands separator HOT 4
- Option to print byte as decimal HOT 10
- Verb '%T' is working incorrectly in formatted print HOT 3
- Add option to skip unexported fields HOT 3
- disable printing of struct metadata HOT 2
- How to use the latest version? HOT 1
- Printf not work correctly HOT 1
- Bug?: Colorize map field names/keys using "FieldName" color scheme setting HOT 3
- ignore private fields in a struct in pretty print golang HOT 1
- Suggestion: implement fmt.Formatter HOT 1
- Cannot format output address
- shorten result print for struct generated by protobuf HOT 5
- Is there any way to get orange text color ? HOT 1
- Option to format time.Time HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pp.