Comments (3)
Just ran into the same thing, did you end up solving it?
I tried both color.RedString
and color.New(color.FgRed).SprintFunc()
with no luck...
Before using color:
After:
Edit: I think this is actually a text/tabwriter
problem because the same issue when just using color codes directly:
colorReset := "\033[0m"
colorRed := "\033[31m"
colorGreen := "\033[32m"
colorYellow := "\033[33m"
from color.
for me this fix works
w.Init(os.Stdout, 0, 8, 4, ' ', 0)
from color.
It's an issue with tabwriter because the escape sequences aren't always the same length, they get used as part of the cell width calculations so some cells appear wider than they are really and don't render correctly
See https://stackoverflow.com/questions/35398497/how-do-i-get-colors-to-work-with-golang-tabwriter
color
could pad the escape sequences to ensure they are all the same length as per the answer in the SO thread above but I suspect it's much trickier and more nuanced than that in practice and there will be a bunch of edge cases that need to be handled
from color.
Related Issues (20)
- [bug] yellow color does not take effect in powershell HOT 1
- Allow forcing color output HOT 2
- Package does not build for Go versions between 1.13 and 1.16 HOT 3
- warn users again wrapping fmt.Sprintf()
- Isn't go get deprecated?
- { // Red is the amount of red Red int // Green is the amount of red Green int // Blue is the amount of red Blue int } HOT 1
- In the Windows, press Ctrl+C, the characters in the cmd.exe are displayed in incorrect colors.
- using underline with a different fg color breaks it HOT 3
- Question: is it possible to create a custom color? HOT 6
- Not Downloading HOT 3
- failed to display color when piped to custom pager HOT 4
- Documentation lies about Println
- downloading HOT 2
- Add arrows and squares with lines HOT 1
- Docker container console support HOT 1
- Set/UnsetWriter asymmetry
- Colorized string doesn't get underlined correctly
- Just a hint: how to make `color` pkg works in `go test` command. HOT 1
- env HOT 1
- CrossedOut not working over SSH
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 color.