github.com/halimath/termcolor

Colorized terminal output for golang


License
Apache-2.0
Install
go get github.com/halimath/termcolor

Documentation

termcolor

CI Status Go Report Card Package Doc Releases

termcolor provides a simple and convenient API to output colorized terminal output with support for terminal detection and color supression.

Installation

termcolor uses go modules and requires Go 1.14 or greater.

$ go get -u github.com/halimath/termcolor

Usage

termcolor provides a Printer type which accepts strings and optional style attributes and outputs colorized output to an io.Writer. Factory functions for STDOUT, STDERR and *os.File are included which automatically detect, if the underlying device is a character device.

p := termcolor.Stdout()

p.Printf("Welcome to %s output!", p.Styled("colored", termcolor.ForegroundCyan), termcolor.Bold)

Changelog

0.1.0

  • Initial release

License

Copyright 2022 Alexander Metzner.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.