Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusOllah committed Oct 11, 2024
1 parent 675c8a4 commit f0a8a82
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

**stripansi** is a Go package for removing [ANSI escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code).

## Basic Usage
## Usage

```go
package main

import (
"strings"
"fmt"
"os"

Expand All @@ -19,8 +20,9 @@ import (
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"
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"
}
```

0 comments on commit f0a8a82

Please sign in to comment.