add
2025-10-27 05:54:52 -05:00
add
2025-10-27 05:54:52 -05:00
2025-10-27 05:58:01 -05:00
add
2025-10-27 05:54:52 -05:00
add
2025-10-27 05:55:38 -05:00
2025-10-27 05:54:47 -05:00

Color

A simple Go library for adding ANSI color codes to terminal output.

Installation

go get git.quad4.io/Go-Libs/Color

Usage

package main

import (
    "fmt"
    "git.quad4.io/Go-Libs/Color"
)

func main() {
    // Basic colors
    fmt.Println(color.Red("This is red text"))
    fmt.Println(color.Green("This is green text"))
    fmt.Println(color.Blue("This is blue text"))

    // Text styles
    fmt.Println(color.Bold("This is bold text"))
    fmt.Println(color.Underline("This is underlined text"))

    // Combinations
    fmt.Println(color.Red(color.Bold("This is bold red text")))

    // Background colors
    fmt.Println(color.BgBlue(color.Yellow("Yellow text on blue background")))
}

Available Functions

Foreground Colors

  • Black(s string) string
  • Red(s string) string
  • Green(s string) string
  • Yellow(s string) string
  • Blue(s string) string
  • Magenta(s string) string
  • Cyan(s string) string
  • White(s string) string

Bright Foreground Colors

  • BrightBlack(s string) string
  • BrightRed(s string) string
  • BrightGreen(s string) string
  • BrightYellow(s string) string
  • BrightBlue(s string) string
  • BrightMagenta(s string) string
  • BrightCyan(s string) string
  • BrightWhite(s string) string

Background Colors

  • BgBlack(s string) string
  • BgRed(s string) string
  • BgGreen(s string) string
  • BgYellow(s string) string
  • BgBlue(s string) string
  • BgMagenta(s string) string
  • BgCyan(s string) string
  • BgWhite(s string) string

Bright Background Colors

  • BgBrightBlack(s string) string
  • BgBrightRed(s string) string
  • BgBrightGreen(s string) string
  • BgBrightYellow(s string) string
  • BgBrightBlue(s string) string
  • BgBrightMagenta(s string) string
  • BgBrightCyan(s string) string
  • BgBrightWhite(s string) string

Text Styles

  • Bold(s string) string
  • Dim(s string) string
  • Italic(s string) string
  • Underline(s string) string
  • Blink(s string) string
  • Reverse(s string) string
  • Hidden(s string) string
  • Strike(s string) string

Utility Functions

  • Reset(s string) string - Removes all color and style formatting

Print Functions

The library also provides print functions that work like fmt.Print, fmt.Println, and fmt.Printf:

  • Print(a ...interface{}) (int, error)
  • Println(a ...interface{}) (int, error)
  • Printf(format string, a ...interface{}) (int, error)
  • Sprint(a ...interface{}) string
  • Sprintln(a ...interface{}) string
  • Sprintf(format string, a ...interface{}) string

Examples

Run the included example:

go run examples/example.go

License

This library is released under the MIT License.

Description
A simple Go library for adding ANSI color codes to terminal output.
Readme MIT 33 KiB
Languages
Go 100%