Source File
noncolorable.go
Belonging Package
github.com/mattn/go-colorable
package colorable
import (
)
// NonColorable holds writer but removes escape sequence.
type NonColorable struct {
out io.Writer
}
// NewNonColorable returns new instance of Writer which removes escape sequence from Writer.
func ( io.Writer) io.Writer {
return &NonColorable{out: }
}
// Write writes data on console
func ( *NonColorable) ( []byte) ( int, error) {
:= bytes.NewReader()
var bytes.Buffer
:
for {
, := .ReadByte()
if != nil {
.WriteTo(.out)
break
}
if != 0x1b {
.WriteByte()
continue
}
_, = .WriteTo(.out)
if != nil {
break
}
, := .ReadByte()
if != nil {
break
}
if != 0x5b {
continue
}
for {
, := .ReadByte()
if != nil {
break
}
if ('a' <= && <= 'z') || ('A' <= && <= 'Z') || == '@' {
break
}
}
}
return len(), nil
}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |