ANSI utilities
To get started, you need a working Go environment. Once available, grab the package here:
$ go get github.com/vutran/ansi
To be documented.
To be documented.
Simple functions to apply a style to a string of text.
package main
import (
"github.com/vutran/ansi/styles"
)
func main() {
msg: = styles.Bold("Hello, world")
fmt.Print(msg)
}
Simple functions to apply a foreground or background color to a string of text.
package main
import (
"github.com/vutran/ansi/colors"
)
func main() {
msg := colors.Blue("Hello, world")
fmt.Print(msg)
}
Display an animated progress loader.
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()
}
- Circle
- Clock
- Dots
- Lines
- Moon
- Triangle
You can mix and decorate your text however you prefer.
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)
}
MIT © Vu Tran