https://github.com/vutran/ansi
ANSI utilities for Go (golang)
https://github.com/vutran/ansi
ansi ascii code escape golang loader spinner
Last synced: 4 months ago
JSON representation
ANSI utilities for Go (golang)
- Host: GitHub
- URL: https://github.com/vutran/ansi
- Owner: vutran
- License: mit
- Created: 2017-09-28T23:53:55.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-09T00:57:12.000Z (about 8 years ago)
- Last Synced: 2025-04-13T15:45:48.179Z (7 months ago)
- Topics: ansi, ascii, code, escape, golang, loader, spinner
- Language: Go
- Homepage: https://godoc.org/github.com/vutran/ansi
- Size: 67.4 KB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ansi
> ANSI utilities
## Install
To get started, you need a working Go environment. Once available, grab the package here:
```
$ go get github.com/vutran/ansi
```
## Usage
### Cursor
To be documented.
### Display
To be documented.
### Style
Simple functions to apply a style to a string of text.
```go
package main
import (
"github.com/vutran/ansi/styles"
)
func main() {
msg: = styles.Bold("Hello, world")
fmt.Print(msg)
}
```
### Colors
Simple functions to apply a foreground or background color to a string of text.
```go
package main
import (
"github.com/vutran/ansi/colors"
)
func main() {
msg := colors.Blue("Hello, world")
fmt.Print(msg)
}
```
### Loaders
Display an animated progress loader.

```go
package main
import (
"github.com/vutran/ansi"
"github.com/vutran/ansi/loaders"
"time"
)
func main() {
s := ansi.Loader(loaders.Dots, 100)
s.SetValue("Loading")
s.Start()
time.Sleep(2 * time.Second)
s.SetValue("Finalizing...")
time.Sleep(2 * time.Second)
s.Stop()
}
```
#### Available Loaders
- Circle
- Clock
- Dots
- Lines
- Moon
- Triangle
### Mix and Match
You can mix and decorate your text however you prefer.
```go
package main
import (
"github.com/vutran/ansi/colors"
"github.com/vutran/ansi/styles"
)
func main() {
// bold, blue text
msg := styles.Bold(colors.Blue("Hello, world"))
fmt.Print(msg)
}
```
## License
MIT © [Vu Tran](https://github.com/vutran/srgnt)