Skip to content

Go console APIs provide a testable abstraction over IO streams and support for color schemes.

License

Notifications You must be signed in to change notification settings

heaths/go-console

Repository files navigation

Go Console APIs

releases reference ci

These Go Console APIs provide a level of abstraction over virtual terminals, implement testable io.Writer, and support color schemes.

Example

You can create a new console using os streams:

package main

import (
    "fmt"

    "github.com/heaths/go-console"
)

func main() {
    con := console.System()
    fmt.Fprintln(con.Stdout(), "Hello, world!")
}

Fake

You can also create a new fake console that uses bytes.Buffer you can access from Stdout() as well:

package main

import (
    "fmt"

    "github.com/heaths/go-console"
)

func main() {
    fake := console.Fake()
    fmt.Fprintln(fake.Stdout(), "Hello, fake!")
    fmt.Println(fake.Stdout().String())
}

License

This project is licensed under the MIT license.

About

Go console APIs provide a testable abstraction over IO streams and support for color schemes.

Topics

Resources

License

Stars

Watchers

Forks

Languages