Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/programyazar/gomicrocolor
Golang bash color output writer
https://github.com/programyazar/gomicrocolor
Last synced: 7 days ago
JSON representation
Golang bash color output writer
- Host: GitHub
- URL: https://github.com/programyazar/gomicrocolor
- Owner: ProgramYazar
- Created: 2017-09-12T06:05:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-12T06:38:43.000Z (about 7 years ago)
- Last Synced: 2024-06-21T06:03:45.168Z (5 months ago)
- Language: Go
- Size: 1.95 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GoMicroColor
Golang bash color output writer# Usage
This library can be use as standart golang io.Writer. Its a simple solution for simple problems on bash environment. Tested on MacOsX but probably works on Linux.# Example
Basic usage of this library...
```go
package mainimport (
"fmt"
"io"
"log"
"os"gcolor "github.com/ProgramYazar/GoMicroColor"
)func listen(ch chan string) {
// better error output
errorOut := gcolor.NewColorWriter(os.Stderr, gcolor.Red, gcolor.BackgroundGreen)tw := io.MultiWriter(
os.Stderr,
os.Stdout,
errorOut,
)
fmt.Fprintf(tw, "received data: %s\n", <-ch)}
func main() {
var ch = make(chan string)
go listen(ch)
ch <- "Error line"
close(ch)greenOutput := gcolor.NewColorWriter(os.Stderr, gcolor.Green, gcolor.BackgroundDefault)
logger := log.New(greenOutput, "", log.LstdFlags)
logger.Println("logger can log this")}
```