github.com/fatih/color: patch to remove race condition...

when printing to a Pipe.

When unpatched,

     Site:      哔哩哔哩 bilibili.com
     Title:     ...
     Type:      video
     Stream:
         [64]  -------------------
         Quality:         高清 720P
         Size:            91.35 MiB (95783022 Bytes)
         # download with: annie -f 64 ...

is instead printed as

     Site:       Title:      Type:       Stream:        [64]  -------------------
         Quality:              Size:                 # download with:
    哔哩哔哩 bilibili.com
    ...
    video

    高清 720P
    91.35 MiB (95783022 Bytes)
    annie -f 64 ...
This commit is contained in:
Zhiming Wang 2020-02-07 13:55:53 +08:00
parent f4850a6ba0
commit 81ee0f1dce
No known key found for this signature in database
GPG Key ID: 5B58F95EC95965D8

View File

@ -204,7 +204,8 @@ func (c *Color) Print(a ...interface{}) (n int, err error) {
c.Set() c.Set()
defer c.unset() defer c.unset()
return fmt.Fprint(Output, a...) return fmt.Print(a...)
// return fmt.Fprint(Output, a...)
} }
// Fprintf formats according to a format specifier and writes to w. // Fprintf formats according to a format specifier and writes to w.
@ -225,7 +226,8 @@ func (c *Color) Printf(format string, a ...interface{}) (n int, err error) {
c.Set() c.Set()
defer c.unset() defer c.unset()
return fmt.Fprintf(Output, format, a...) return fmt.Printf(format, a...)
// return fmt.Fprintf(Output, format, a...)
} }
// Fprintln formats using the default formats for its operands and writes to w. // Fprintln formats using the default formats for its operands and writes to w.
@ -248,7 +250,8 @@ func (c *Color) Println(a ...interface{}) (n int, err error) {
c.Set() c.Set()
defer c.unset() defer c.unset()
return fmt.Fprintln(Output, a...) return fmt.Println(a...)
// return fmt.Fprintln(Output, a...)
} }
// Sprint is just like Print, but returns a string instead of printing it. // Sprint is just like Print, but returns a string instead of printing it.