core

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IsStderrTerm bool
	IsStdoutTerm bool

	UserAgent string
	Version   string
)

Functions

func GetBuildInfo

func GetBuildInfo() []byte

GetBuildInfo returns the JSON encoded build information for the executable.

func PointerTo

func PointerTo[T any](t T) *T

PointerTo returns a pointer to the value provided.

Types

type Color

type Color int

Color represents the options for enabling or disabling color output.

const (
	ColorUnknown Color = iota
	ColorAuto
	ColorOn
	ColorOff
)

type ErrRequestTimedOut

type ErrRequestTimedOut struct {
	Timeout time.Duration
}

ErrRequestTimedOut represents the error when the request times out.

func (ErrRequestTimedOut) Error

func (err ErrRequestTimedOut) Error() string

type Format

type Format int

Format represents the options for enabling or disabling formatting.

const (
	FormatUnknown Format = iota
	FormatAuto
	FormatOff
	FormatOn
)

type HTTPVersion

type HTTPVersion int

HTTPVersion represents the options for the maximum allowed HTTP version.

const (
	HTTPDefault HTTPVersion = iota
	HTTP1
	HTTP2
)

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

Handle represents a handle for stderr and stdout Printers.

func NewHandle

func NewHandle(c Color) *Handle

NewHandle returns a new Handle given the provided color configuration.

func (*Handle) Stderr

func (h *Handle) Stderr() *Printer

Stderr returns the Printer for stderr.

func (*Handle) Stdout

func (h *Handle) Stdout() *Printer

Stdout returns the Printer for stdout.

type KeyVal

type KeyVal struct {
	Key, Val string
}

KeyVal represents a generic key & value struct.

type Printer

type Printer struct {
	// contains filtered or unexported fields
}

Printer allows for writing data with optional ANSI escape sequences based on the color settings for a target.

func (*Printer) Bytes

func (p *Printer) Bytes() []byte

Bytes returns the current contents of the buffer.

func (*Printer) Flush

func (p *Printer) Flush() error

Flush writes any buffered data to the underlying file.

func (*Printer) Read

func (p *Printer) Read(b []byte) (int, error)

Read reads from the buffer.

func (*Printer) Reset

func (p *Printer) Reset()

Reset resets any active escape sequences.

func (*Printer) Set

func (p *Printer) Set(s Sequence)

Set writes the provided Sequence.

func (*Printer) Write

func (p *Printer) Write(b []byte) (int, error)

Write writes the provided data to the buffer.

func (*Printer) WriteRune

func (p *Printer) WriteRune(r rune) (int, error)

WriteRune writes the provided rune to the buffer.

func (*Printer) WriteString

func (p *Printer) WriteString(s string) (int, error)

WriteString writes the provided string to the buffer.

func (*Printer) WriteTo

func (p *Printer) WriteTo(w io.Writer) (int64, error)

WriteTo writes the buffered data to the provided io.Writer.

type PrinterTo

type PrinterTo interface {
	PrintTo(*Printer)
}

PrinterTo represents the interface for printing to a Printer.

type Sequence

type Sequence string

Sequence represents an ANSI escape sequence.

const (
	Bold      Sequence = "1"
	Dim       Sequence = "2"
	Italic    Sequence = "3"
	Underline Sequence = "4"

	Black   Sequence = "30"
	Red     Sequence = "31"
	Green   Sequence = "32"
	Yellow  Sequence = "33"
	Blue    Sequence = "34"
	Magenta Sequence = "35"
	Cyan    Sequence = "36"
	White   Sequence = "37"
	Default Sequence = "39"
)

type SignalError

type SignalError string

SignalError represents the error when a signal is caught.

func (SignalError) Error

func (err SignalError) Error() string

type ValueError

type ValueError struct {
	// contains filtered or unexported fields
}

func NewValueError

func NewValueError(option, value, usage string, isFile bool) *ValueError

func (*ValueError) Error

func (err *ValueError) Error() string

func (*ValueError) PrintTo

func (err *ValueError) PrintTo(p *Printer)

type Verbosity

type Verbosity int

Verbosity represents how verbose the output should be.

const (
	VSilent Verbosity = iota
	VNormal
	VVerbose
	VExtraVerbose
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳