Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
github.com/kortschak/ct
import "github.com/kortschak/ct"
Package ct provides ANSI terminal text coloring and decoration support.
type Color int
Color is a basic color list selector. Not all colors are available on all platforms.
const (
Black Color = iota
Red
Green
Yellow
Blue
Magenta
Cyan
LightGray
Gray
BoldRed
BoldGreen
BoldYellow
BoldBlue
BoldMagenta
BoldCyan
White
)
type Mode uint64
Mode specifies terminal rendering modes via its Render method. Modes should be bitwise or'd together. Not all modes are available on all platforms.
A Mode is essentially a bit field of colors and decoration flags. The layout of a Mode is as follows:
bits 0-3 - color of foreground
bit 4 - set foreground color
bits 5-7 - color of background
bit 8 - set background color
bits 9-16 - XTerm color of foreground
bit 17 - set XTerm foreground color
bits 18-25 - XTerm color of background
bit 26 - set XTerm background color
bits 27- - text decoration flags
highest bit - do not reset terminal after rendering
XTerm colors take priority over normal terminal colors if supported by the platform.
const (
Reset Mode = 1 << (iota + colorBits)
Bold
Faint
Italic
Underline
BlinkSlow
BlinkRapid
Negative
Conceal
CrossedOut
NoResetAfter Mode = 1 << 63
)
func Bg(c Color) Mode
Bg returns a background color Mode based on the provided Color.
func Fg(c Color) Mode
Fg returns a foreground color Mode based on the provided Color.
func XTermBg(c byte) Mode
XTermBg returns an XTerm background color Mode based on the provided XTerm color.
func XTermFg(c byte) Mode
XTermFg returns an XTerm foreground color Mode based on the provided XTerm color.
func (m Mode) Paint(v ...interface{}) fmt.Formatter
Paint returns a fmt.Formatter that will apply the mode to the printed values of the parameters.
package main
import (
"fmt"
"github.com/kortschak/ct"
)
var (
info = (ct.Fg(ct.Black) | ct.XTermFg(16) | ct.Bold).Paint
warn = (ct.Fg(ct.White) | ct.Bg(ct.Red)).Paint
)
func main() {
fmt.Println(warn("WARNING:"), "Danger, Will Robinson! Danger! ")
fmt.Println(info("INFO:"), "Doctor Smith, please. You're making the Robot very unhappy!")
}
Generated by godoc2md
FAQs
Unknown package
Did you know?
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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.