stripansi is a Go package for removing ANSI escape sequences.
package main
import (
"strings"
"fmt"
"io"
"os"
"github.com/MatusOllah/stripansi"
)
func main() {
s := "\x1b[38;5;140mhello\x1b[0m world"
fmt.Println(stripansi.String(s)) // "hello world"
fmt.Println(string(stripansi.Bytes([]byte(s)))) // "hello world"
stripansi.NewWriter(os.Stdout).Write([]byte(s)) // "hello world"
io.Copy(os.Stdout, stripansi.NewReader(strings.NewReader(s))) // "hello world"
}