Skip to content

Commit

Permalink
feat: added demo example
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinJWendt committed Jul 13, 2024
1 parent f3416d2 commit 1502e44
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,32 @@ import (

func Example_demo() {
// Simple coloring
fmt.Println("Hello, " + color.Red("World") + "!")
fmt.Println("Hello, " + color.Green("World") + "!")

fmt.Println() // blank line

// Theme colors - can be customized in init() function if needed
fmt.Println(color.Success("Success message"))
fmt.Println(color.Info("Info message"))
fmt.Println(color.Warning("Warning message"))
fmt.Println(color.Error("Error message"))
fmt.Println(color.Fatal("Fatal message"))

fmt.Println() // blank line

// Supports ANSI colors
ansiRed := color.NewStyle(color.ANSIRed, nil).Sprint
fmt.Println(ansiRed("This is printed red using an ANSI color code"))

// Supports ANSI256 colors
ansi256Red := color.NewStyle(color.ANSI256Color(196), nil).Sprint
fmt.Println(ansi256Red("This is printed red using an ANSI256 color code"))

// Supports RGB colors
redRGB := color.NewStyle(color.NewColorFromRGB(255, 0, 0), nil).Sprint
fmt.Println(redRGB("This is printed red using a RGB color code"))

// Supports hex colors
redHex := color.NewStyle(color.NewColorFromHex("#ff0000"), nil).Sprint
fmt.Println(redHex("This is printed red using a hex color code"))
}

0 comments on commit 1502e44

Please sign in to comment.