Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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 main

import (
"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")

}

```