Skip to content
/ rich-go Public

Inspired from Python's "Rich" package, styling stdouts in go to a more human-readible format.

Notifications You must be signed in to change notification settings

RVFET/rich-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎨 Rich-go

min go version

Rich-go is a Go library for printing text in terminal in a more readable and eye-pleasing way. This library is meant to be a Go equivalent of the Python library Rich by Textualize.

Note: This library is still in development and is not yet ready for production use.

🚀 Getting Started

Installation

To install Rich-go, you just need to go get it:

go get github.com/rvfet/rich-go

Usage

Rich-go aims to be as simple as possible to use. Here is a simple example:

package main

import (
  "github.com/rvfet/rich-go"
)

func main() {
  rich.Print("Hello, World!")
}

Output

Common logging functions are also available:

package main

import (
  "github.com/rvfet/rich-go"
)

func main() {
  rich.Info("Connecting to database...")
  rich.Warning("Connection timed out, retrying...")
  rich.Error("Connection failed!")
  rich.Success("Connection successfully established!")
  rich.Debug("Connection took 2.5s")
}

Output

Rich-go also supports inline styles, arguments and nesteding. Here's a crazy example:

package main

import (
  "github.com/rvfet/rich-go"
)

func main() {
	rich.Print("[x]Hello[/] [green][i]World[/] and its", 8, "[white]billion[/] [b]beautiful[/] [red]inhabitants[/]!")
	rich.Debug("This API [yellow]has to be[/yellow] [u]revised[/u] and [u]optimized[/u]!")
}

Output

Note: For icons to work, you need to have a font that supports them. You can use the Nerd Fonts for this.

For real-world usage example and quickly getting started, check out the Example code.

Output


📦 Roadmap

  • Basic text printing
  • Basic logging functions
  • Inline styles
  • Making Print and logging functions variadic
  • Handling nested styles in a better way
  • Implementing string formatting: rich.Print("Hello, %s!", name) or rich.Print("Hello, {name}!")
  • Making monkey-patching easier and improving modularity
  • Perhaps, a docs website?
  • Config file for customizing styles
  • Logging to file

🤝 Contributing

Contributions are always welcome! Feel free to open issues or pull requests.

📦 Built With

  • Go - The Go Programming Language And it's standard libraries.

📧 Contact

If you have any questions or suggestions, feel free to contact me at [email protected].

About

Inspired from Python's "Rich" package, styling stdouts in go to a more human-readible format.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages