Skip to content

MatusOllah/stripansi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stripansi

Go Reference Go Report Card

stripansi is a Go package for removing ANSI escape sequences.

Usage

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"
}