Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/makyo/ansigo

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/makyo/ansigo

  • v0.0.0-20221219232024-4dc1ef7efe9a
  • Source
  • Go
  • Socket score

Version published
Created
Source

Build Status GoDoc Support me on Patreon Buy me a Coffee Support me on LiberaPay

ansigo

ANSI escape-code library for Golang.

Pretty colors

For the colors and attributes, see the project page.

Usage

package main

import (
	"fmt"

	ansi "github.com/makyo/ansigo"
)

func main() {
	// You can get attributes...
	bold, err := ansi.Attributes.Find("bold")
	if err != nil {
		panic(err)
	}
	fmt.Println(bold.Apply("Some bold text"))
	fmt.Print("\n")

	// Or colors from three different spaces...
	red1, err := ansi.Colors8.Find("red")
	if err != nil {
		panic(err)
	}
	red2, err := ansi.Colors256.Find("DarkRed")
	if err != nil {
		panic(err)
	}
	red3, err := ansi.Colors24bit.Find("#661126")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s %s %s\n", red1.FG("Three"), red2.BG("different"), red3.BG(red1.FG("reds")))
	fmt.Print("\n")

	// Or you can let ansigo figure out the hard work.
	s, err := ansi.ApplyOne("underline", "Some text.")
	if err != nil {
		panic(err)
	}
	fmt.Println(s)
	fmt.Print("\n")

	// But all this error checking is tiresome, and maybe you don't want to
	// have to keep nesting lookups.
	fmt.Println(ansi.MaybeApply("bold+brightyellow+rgb(145, 20, 31):bg+blink", "Warning!"))
}

FAQs

Package last updated on 19 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc