rgblog

package module
v0.0.0-...-1abc5df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2017 License: MIT Imports: 1 Imported by: 6

README

RgbLog

The rgblog package provides a set of functions that wrap the standard fmt.Printf function. Each function provided applies a different color to the formatted output, using ANSI escape codes. This package assumes that your standard output (i.e. your terminal) has support for such escape codes.

ANSI Codes from Wikipedia:

Color Foreground Code Background Code
Black 30 40
Red 31 41
Green 32 42
Yellow 33 43
Blue 34 44
Magenta 35 45
Cyan 36 46
White 37 47

Installation

Run go get github.com/foresthoffman/rgblog

Importing

Import the package by including github.com/foresthoffman/rgblog in your import block.

e.g.

package main

import(
	...
	"github.com/foresthoffman/rgblog"
)

If you want to reference the package via an alias, so that you don't have to type rgblog.Xxx() every time, try this:

import(
	...
	rgb "github.com/foresthoffman/rgblog"
)

What will it look like for me?

If you want to see what the output will look like without having to write a quick Go program to use all the functions, run the code below in your shell.

echo -e "
\033[0;37mNormal Colors\033[0m
Black\t\033[0;30mThe quick brown fox jumped over the lazy dog\033[0m
Red\t\033[0;31mThe quick brown fox jumped over the lazy dog\033[0m
Green\t\033[0;32mThe quick brown fox jumped over the lazy dog\033[0m
Yellow\t\033[0;33mThe quick brown fox jumped over the lazy dog\033[0m
Blue\t\033[0;34mThe quick brown fox jumped over the lazy dog\033[0m
Magenta\t\033[0;35mThe quick brown fox jumped over the lazy dog\033[0m
Cyan\t\033[0;36mThe quick brown fox jumped over the lazy dog\033[0m
White\t\033[0;37mThe quick brown fox jumped over the lazy dog\033[0m

\033[1;37mBold/Bright Colors\033[0m
Black\t\033[1;30mThe quick brown fox jumped over the lazy dog\033[0m
Red\t\033[1;31mThe quick brown fox jumped over the lazy dog\033[0m
Green\t\033[1;32mThe quick brown fox jumped over the lazy dog\033[0m
Yellow\t\033[1;33mThe quick brown fox jumped over the lazy dog\033[0m
Blue\t\033[1;34mThe quick brown fox jumped over the lazy dog\033[0m
Magenta\t\033[1;35mThe quick brown fox jumped over the lazy dog\033[0m
Cyan\t\033[1;36mThe quick brown fox jumped over the lazy dog\033[0m
White\t\033[1;37mThe quick brown fox jumped over the lazy dog\033[0m
"

That's all, enjoy!

Documentation

Overview

Package rgblog provides functions to color standard output using ANSI escape codes. See, https://en.wikipedia.org/wiki/ANSI_escape_code#Colors, for more detail on ANSI codes.

Here's an example:

import(
    rgb "github.com/foresthoffman/rgblog"
)

func main() {
    rgb.YPrintf("Hello, %s!\n", "World") // the format gets wrapped with "\033[0;33m"
                                         // and "\033[0m", before being sent to
                                         // standard output via fmt.Printf()
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BkPrintf

func BkPrintf(f string, a ...interface{})

Formats the output according to the format string and uses the provided interface data to fill it in. The output is wrapped with ANSI color escape codes, which can be used to make standard output more readable, in supporting shells.

Output color: black

func BlPrintf

func BlPrintf(f string, a ...interface{})

Formats the output according to the format string and uses the provided interface data to fill it in. The output is wrapped with ANSI color escape codes, which can be used to make standard output more readable, in supporting shells.

Output color: blue

func CPrintf

func CPrintf(f string, a ...interface{})

Formats the output according to the format string and uses the provided interface data to fill it in. The output is wrapped with ANSI color escape codes, which can be used to make standard output more readable, in supporting shells.

Output color: cyan

func GPrintf

func GPrintf(f string, a ...interface{})

Formats the output according to the format string and uses the provided interface data to fill it in. The output is wrapped with ANSI color escape codes, which can be used to make standard output more readable, in supporting shells.

Output color: green

func MPrintf

func MPrintf(f string, a ...interface{})

Formats the output according to the format string and uses the provided interface data to fill it in. The output is wrapped with ANSI color escape codes, which can be used to make standard output more readable, in supporting shells.

Output color: magenta

func RPrintf

func RPrintf(f string, a ...interface{})

Formats the output according to the format string and uses the provided interface data to fill it in. The output is wrapped with ANSI color escape codes, which can be used to make standard output more readable, in supporting shells.

Output color: red

func WPrintf

func WPrintf(f string, a ...interface{})

Formats the output according to the format string and uses the provided interface data to fill it in. The output is wrapped with ANSI color escape codes, which can be used to make standard output more readable, in supporting shells.

Output color: white

func YPrintf

func YPrintf(f string, a ...interface{})

Formats the output according to the format string and uses the provided interface data to fill it in. The output is wrapped with ANSI color escape codes, which can be used to make standard output more readable, in supporting shells.

Output color: yellow

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL