raingo

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: OSL-3.0 Imports: 3 Imported by: 0

README

raingo

Rainbow + Go = raingo

Go Report Card License Latest Release Go Reference

raingo is a simple Go library for printing colourful, formatted text to the terminal.

Features:

  • Full RGB text and background colours
  • Colour gradients across a string
  • Text formatting: bold, dim, italic, underline
  • Auto-detects non-terminal output (e.g. pipes, CI) and falls back to plain text

Importing

  1. Run:
go get codeberg.org/owen07/raingo
  1. Import the library in your source files:
import "codeberg.org/owen07/raingo"

Usage Examples

Colour values are RGB integers in the range 0-255.

Gradient functions take a start and end colour: (startR, startG, startB, endR, endG, endB).

When competing options are both passed (e.g. BGColour and BGGradient), the last one in the argument list takes effect.

Coloured Text
raingo.Println("Apple", raingo.TextColour(220, 40, 40))
Coloured Background
raingo.Println("Banana", raingo.BGColour(255, 225, 53))
Coloured Text & Background
raingo.Println("Orange & Strawberry",
    raingo.TextColour(255, 140, 0),
    raingo.BGColour(220, 50, 50),
)
Text Formatting
raingo.Println("Bold", raingo.Bold())
raingo.Println("Dim", raingo.Dim())
raingo.Println("Italic", raingo.Italic())
raingo.Println("Underline", raingo.Underline())
Coloured Text Gradient
raingo.Println("Blueberry to Grape", raingo.TextGradient(79, 97, 163, 111, 45, 168))
Coloured Text Gradient & Coloured Background Gradient
raingo.Println("Cherry to Blackberry & Lemon to Lime",
    raingo.TextGradient(153, 25, 25, 43, 19, 56),
    raingo.BGGradient(255, 247, 0, 166, 216, 84),
)
Coloured Text Gradient & Text Formatting
raingo.Println("Cranberry to Raspberry",
    raingo.TextGradient(153, 0, 51, 227, 11, 93),
    raingo.Bold(),
    raingo.Underline(),
)
Print a Value Using fmt.Sprintf()
raingo.Println(fmt.Sprintf("%s", "Peach"),
    raingo.TextColour(255, 218, 185),
)
Plain Text (No Formatting)
raingo.Println("Plain Text")

License

raingo is licensed under the Open Software License version 3.0.

Documentation

Overview

Package raingo provides functions for printing colourful, formatted text to the terminal using ANSI escape codes. Formatting is automatically disabled when output is not a terminal, such as when piped to a file or another process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(text string, opts ...Option)

Print formats and prints styled text to standard output. Formatting is automatically disabled when output is not a terminal.

func Println

func Println(text string, opts ...Option)

Println formats and prints styled text to standard output, followed by a newline. Formatting is automatically disabled when output is not a terminal.

Types

type Option

type Option func(*style)

Option configures the style applied to text when printing. Multiple Options can be passed to Print and Println to combine styles.

func BGColour

func BGColour(r, g, b uint8) Option

BGColour sets the background colour using RGB values (0-255).

func BGGradient

func BGGradient(r1, g1, b1, r2, g2, b2 uint8) Option

BGGradient sets a left-to-right RGB gradient on the background, interpolating from (r1, g1, b1) to (r2, g2, b2) across each character.

func Bold

func Bold() Option

Bold makes the text bold.

func Dim

func Dim() Option

Dim makes the text dim.

func Italic

func Italic() Option

Italic makes the text italic.

func TextColour

func TextColour(r, g, b uint8) Option

TextColour sets the text colour using RGB values (0-255).

func TextGradient

func TextGradient(r1, g1, b1, r2, g2, b2 uint8) Option

TextGradient sets a left-to-right RGB gradient on the text, interpolating from (r1, g1, b1) to (r2, g2, b2) across each character.

func Underline

func Underline() Option

Underline underlines the text.

Jump to

Keyboard shortcuts

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