1
0
mirror of https://github.com/containers/skopeo.git synced 2025-05-12 18:04:44 +00:00
skopeo/vendor/github.com/acarl005/stripansi
Valentin Rothberg a7297d4db7 vendor github.com/containers/image/v5@v5.2.0
See release notes:
https://github.com/containers/image/releases/tag/v5.2.0

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-02-03 16:49:05 +01:00
..
LICENSE vendor github.com/containers/image/v5@v5.2.0 2020-02-03 16:49:05 +01:00
README.md vendor github.com/containers/image/v5@v5.2.0 2020-02-03 16:49:05 +01:00
stripansi.go vendor github.com/containers/image/v5@v5.2.0 2020-02-03 16:49:05 +01:00

Strip ANSI

This Go package removes ANSI escape codes from strings.

Ideally, we would prevent these from appearing in any text we want to process. However, sometimes this can't be helped, and we need to be able to deal with that noise. This will use a regexp to remove those unwanted escape codes.

Install

$ go get -u github.com/acarl005/stripansi

Usage

import (
	"fmt"
	"github.com/acarl005/stripansi"
)

func main() {
	msg := "\x1b[38;5;140m foo\x1b[0m bar"
	cleanMsg := stripansi.Strip(msg)
	fmt.Println(cleanMsg) // " foo bar"
}