https://github.com/heaths/go-console
Go console APIs provide a testable abstraction over IO streams and support for color schemes.
https://github.com/heaths/go-console
console
Last synced: about 2 months ago
JSON representation
Go console APIs provide a testable abstraction over IO streams and support for color schemes.
- Host: GitHub
- URL: https://github.com/heaths/go-console
- Owner: heaths
- License: mit
- Created: 2021-09-15T06:14:14.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-11-23T06:05:35.000Z (over 3 years ago)
- Last Synced: 2025-01-01T10:16:46.361Z (over 1 year ago)
- Topics: console
- Language: Go
- Homepage:
- Size: 34.2 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Go Console APIs
[](https://github.com/heaths/go-console/releases/latest)
[](https://pkg.go.dev/github.com/heaths/go-console)
[](https://github.com/heaths/go-console/actions/workflows/ci.yml)
These [Go](https://golang.org) 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:
```go
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:
```go
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](LICENSE.txt).