tint

package module
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 2 Imported by: 0

README

GitHub Workflow Status (branch) GoDoc Coverage Status Supported Go Versions GitHub Release Go Report Card

tint

tint is a simple Go package to add vibrant colors to console output with an extensive palette and simple API.


CHINESE README

中文说明

Main Features

🌈 Extensive Palette: Elegant colors including basic colors, bright variants, and unique tones ⚡ Simple API: Sprint method to handle simple string coloring and ShowMessage to show highlighted output 🔧 Custom Colors: NewCOLOR function to create custom tint configurations 📝 Multi-line Support: Automatic handling of multi-line text with consistent coloring 🎨 Rich Palette: From basic RED, GREEN, BLUE to exotic CORAL, TEAL, VIOLET, GOLD, SILVER, NAVY

Installation

go get github.com/yylego/tint

Usage

Basic Usage
package main

import (
	"fmt"

	"github.com/yylego/tint"
)

func main() {
	// Basic tint
	fmt.Println(tint.RED.Sprint("print RED text"))
	fmt.Println(tint.GREEN.Sprint("print GREEN text"))
	fmt.Println(tint.BLUE.Sprint("print BLUE text"))

	// Extended tint
	fmt.Println(tint.ORANGE.Sprint("print ORANGE text"))
	fmt.Println(tint.VIOLET.Sprint("print VIOLET text"))
	fmt.Println(tint.TEAL.Sprint("print TEAL text"))
	fmt.Println(tint.INDIGO.Sprint("print INDIGO text"))
	fmt.Println(tint.CORAL.Sprint("print CORAL text"))
}
Show Highlighted Messages
package main

import (
	"github.com/yylego/tint"
)

func main() {
	// Show important messages with borders
	tint.CYAN.ShowMessage("Important notification message")
	tint.YELLOW.ShowMessage("Warning message")
	tint.RED.ShowMessage("Problem message")
}
Custom Colors
package main

import (
	"fmt"
	"github.com/yylego/tint"
)

func main() {
	// Create custom tint with ANSI codes
	customColor := tint.NewCOLOR("\033[102m%s\033[0m") // Green background
	fmt.Println(customColor.Sprint("Custom colored text"))
}

API Reference

COLOR Type Methods
  • Sprint(args ...interface{}) string - Format arguments with tint
  • Sprintf(format string, args ...interface{}) string - Format with format string, then add tint
  • ShowMessage(msgs ...any) - Show message with decorative borders

Examples

Check out the TEST-FILE to see more usage examples and tint demonstrations.

📄 License

MIT License - see LICENSE.


💬 Contact & Feedback

Contributions are welcome! Report bugs, suggest features, and contribute code:

  • 🐛 Mistake reports? Open an issue on GitHub with reproduction steps
  • 💡 Fresh ideas? Create an issue to discuss
  • 📖 Documentation confusing? Report it so we can improve
  • 🚀 Need new features? Share the use cases to help us understand requirements
  • Performance issue? Help us optimize through reporting slow operations
  • 🔧 Configuration problem? Ask questions about complex setups
  • 📢 Follow project progress? Watch the repo to get new releases and features
  • 🌟 Success stories? Share how this package improved the workflow
  • 💬 Feedback? We welcome suggestions and comments

🔧 Development

New code contributions, follow this process:

  1. Fork: Fork the repo on GitHub (using the webpage UI).
  2. Clone: Clone the forked project (git clone https://github.com/yourname/repo-name.git).
  3. Navigate: Navigate to the cloned project (cd repo-name)
  4. Branch: Create a feature branch (git checkout -b feature/xxx).
  5. Code: Implement the changes with comprehensive tests
  6. Testing: (Golang project) Ensure tests pass (go test ./...) and follow Go code style conventions
  7. Documentation: Update documentation to support client-facing changes
  8. Stage: Stage changes (git add .)
  9. Commit: Commit changes (git commit -m "Add feature xxx") ensuring backward compatible code
  10. Push: Push to the branch (git push origin feature/xxx).
  11. PR: Open a merge request on GitHub (on the GitHub webpage) with detailed description.

Please ensure tests pass and include relevant documentation updates.


🌟 Support

Welcome to contribute to this project via submitting merge requests and reporting issues.

Project Support:

  • Give GitHub stars if this project helps you
  • 🤝 Share with teammates and (golang) programming friends
  • 📝 Write tech blogs about development tools and workflows - we provide content writing support
  • 🌟 Join the ecosystem - committed to supporting open source and the (golang) development scene

Have Fun Coding with this package! 🎉🎉🎉


GitHub Stars

Stargazers

Documentation

Index

Constants

View Source
const (
	BLACK   = COLOR("\033[1;30m%s\033[0m") // Bold Black // 粗体黑色
	RED     = COLOR("\033[1;31m%s\033[0m") // Bold Red // 粗体红色
	GREEN   = COLOR("\033[1;32m%s\033[0m") // Bold Green // 粗体绿色
	YELLOW  = COLOR("\033[1;33m%s\033[0m") // Bold Yellow // 粗体黄色
	BLUE    = COLOR("\033[1;34m%s\033[0m") // Bold Blue // 粗体蓝色
	MAGENTA = COLOR("\033[1;35m%s\033[0m") // Bold Magenta // 粗体洋红
	CYAN    = COLOR("\033[1;36m%s\033[0m") // Bold Cyan // 粗体青色
	WHITE   = COLOR("\033[1;37m%s\033[0m") // Bold White // 粗体白色

	GRAY    = COLOR("\033[1;90m%s\033[0m") // Bold Bright Black // 粗体亮黑色 (灰色)
	SCARLET = COLOR("\033[1;91m%s\033[0m") // Bold Bright Red // 粗体鲜红色
	LIME    = COLOR("\033[1;92m%s\033[0m") // Bold Bright Green // 粗体柠檬绿色
	AMBER   = COLOR("\033[1;93m%s\033[0m") // Bold Bright Yellow // 粗体琥珀色
	AZURE   = COLOR("\033[1;94m%s\033[0m") // Bold Bright Blue // 粗体天蓝色
	PINK    = COLOR("\033[1;95m%s\033[0m") // Bold Bright Magenta // 粗体粉红色
	AQUA    = COLOR("\033[1;96m%s\033[0m") // Bold Bright Cyan // 粗体水青色
	IVORY   = COLOR("\033[1;97m%s\033[0m") // Bold Bright White // 粗体雪白

	ORANGE    = COLOR("\033[1;38;5;202m%s\033[0m") // Bold Orange // 粗体橙色
	VIOLET    = COLOR("\033[1;38;5;93m%s\033[0m")  // Bold Violet // 粗体紫罗兰色
	TEAL      = COLOR("\033[1;38;5;30m%s\033[0m")  // Bold Teal // 粗体青绿色
	INDIGO    = COLOR("\033[1;38;5;54m%s\033[0m")  // Bold Indigo // 粗体靛蓝色
	CORAL     = COLOR("\033[1;38;5;203m%s\033[0m") // Bold Coral // 粗体珊瑚色
	BRONZE    = COLOR("\033[1;38;5;130m%s\033[0m") // Bold Bronze // 粗体青铜色
	CRIMSON   = COLOR("\033[1;38;5;124m%s\033[0m") // Bold Crimson // 粗体深红色
	TURQUOISE = COLOR("\033[1;38;5;45m%s\033[0m")  // Bold Turquoise // 粗体绿松石色

	GOLD   = COLOR("\033[1;38;5;220m%s\033[0m") // Bold Gold // 粗体金色
	SILVER = COLOR("\033[1;38;5;7m%s\033[0m")   // Bold Silver // 粗体银色
	NAVY   = COLOR("\033[1;38;5;17m%s\033[0m")  // Bold Navy // 粗体海军蓝
)

Variables

This section is empty.

Functions

This section is empty.

Types

type COLOR

type COLOR string

func NewCOLOR

func NewCOLOR(format string) COLOR

func (COLOR) ShowMessage

func (co COLOR) ShowMessage(msgs ...any)

func (COLOR) Sprint

func (co COLOR) Sprint(args ...interface{}) string

Sprint joins arguments with space and applies tint to each line Sprint 用空格连接参数并对每行应用颜色

func (COLOR) Sprintf

func (co COLOR) Sprintf(format string, args ...interface{}) string

Sprintf formats arguments according to format string and applies tint Sprintf 根据格式字符串格式化参数并应用颜色

Jump to

Keyboard shortcuts

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