Documentation
¶
Index ¶
- Constants
- Variables
- func AppendTerminalSafeBytes(dst, src []byte) []byte
- func BuildTLSConfig(options TLSConfigOptions) *tls.Config
- func CheckedAddInt(a, b int) (int, bool)
- func CheckedAddInt64(a, b int64) (int64, bool)
- func CheckedAddUint64(a, b uint64) (uint64, bool)
- func CheckedInt64ToInt(v int64) (int, bool)
- func CheckedInt64ToUint64(v int64) (uint64, bool)
- func CheckedIntToInt64(v int) (int64, bool)
- func CheckedIntToUint64(v int) (uint64, bool)
- func CheckedMulInt(a, b int) (int, bool)
- func CheckedUint64ToInt(v uint64) (int, bool)
- func CheckedUint64ToInt64(v uint64) (int64, bool)
- func CutTrimmed(s, sep string) (string, string, bool)
- func DetectContentType(r io.Reader, filename string) (io.Reader, string, error)
- func GetBuildInfo(verbose ...bool) []byte
- func GetTerminalCols() int
- func GetVCSRevision() string
- func IsBrokenPipe(err error) bool
- func IsSensitiveHeader(name string) bool
- func IsSensitiveQueryKey(name string) bool
- func JoinIPHostPort(address net.IPAddr, port string) string
- func LimitedReader(r io.Reader, max int64) io.Reader
- func NewCancelledError(cause error) error
- func NewCategoryError(category ErrorCategory, cause error) error
- func NewNetworkError(cause error) error
- func NewPartialError(cause error) error
- func NewRemoteError(cause error) error
- func NewUpdateNoOpError(cause error) error
- func NewUsageError(cause error) error
- func ParseSeconds(value string) (time.Duration, error)
- func ReadAllLimited(r io.Reader, max int64, subsystem string) ([]byte, error)
- func RedactHeaderValue(name, value string) string
- func RedactedErrorText(err error) string
- func RedactedQuery(rawQuery string) string
- func RedactedURL(u *url.URL) string
- func SignalExitCode(err error) (int, bool)
- func TLSVerificationName(host string) string
- func TerminalSafeBytes(src []byte) []byte
- func TerminalSafeText(s string) string
- func ValidateECHPolicy(mode ECHMode, httpVersion HTTPVersion, min, max uint16) error
- func ValidateTLSVersions(min, max uint16) error
- func WriteErrorMsg(p *Printer, err error)
- func WriteErrorMsgNoFlush(p *Printer, err error)
- func WriteInfoMsg(p *Printer, msg string)
- func WriteWarningMsg(p *Printer, msg string)
- func WriteWarningMsgIf(p *Printer, msg string, silent bool)
- type BoundedBuffer
- type Budget
- func (b Budget) Check(phase string) error
- func (b Budget) Child(phase string) BudgetChild
- func (b Budget) ConnectionTimeoutError(phase string) error
- func (b Budget) Deadline() (time.Time, bool)
- func (b Budget) Err() error
- func (b Budget) ErrAt(now time.Time, phase string) error
- func (b Budget) Expired() bool
- func (b Budget) Limited() bool
- func (b Budget) Remaining() (time.Duration, bool)
- func (b Budget) RemainingAt(now time.Time) (time.Duration, bool)
- func (b Budget) TimeoutError(phase string) error
- func (b Budget) WithConnectionContext(parent context.Context, phase string) (context.Context, context.CancelFunc)
- func (b Budget) WithContext(parent context.Context, phase string) (context.Context, context.CancelFunc)
- type BudgetChild
- type CategoryError
- type Color
- type CompressionMode
- type ECHMode
- type ErrConnectionTimedOut
- type ErrRequestTimedOut
- type ErrorCategory
- type FileNotExistsError
- type Format
- type HTTPVersion
- type Handle
- type ImageSetting
- type KeyVal
- type LimitError
- type PagerMode
- type Printer
- func (p *Printer) Bytes() []byte
- func (p *Printer) Discard()
- func (p *Printer) EndHyperlink()
- func (p *Printer) Err() error
- func (p *Printer) Flush() error
- func (p *Printer) IsTerminal() bool
- func (p *Printer) NewBoundedWriter(w io.Writer, max int64, subsystem string) *Printer
- func (p *Printer) NewWriter(w io.Writer) *Printer
- func (p *Printer) Read(b []byte) (int, error)
- func (p *Printer) Reset()
- func (p *Printer) Set(s Sequence)
- func (p *Printer) StartHyperlink(url string) bool
- func (p *Printer) Write(b []byte) (int, error)
- func (p *Printer) WriteInfoPrefix()
- func (p *Printer) WriteRequestPrefix()
- func (p *Printer) WriteResponsePrefix()
- func (p *Printer) WriteRune(r rune) (int, error)
- func (p *Printer) WriteString(s string) (int, error)
- func (p *Printer) WriteStringUntrusted(s string) (int, error)
- func (p *Printer) WriteTo(w io.Writer) (int64, error)
- func (p *Printer) WriteUntrusted(b []byte) (int, error)
- type PrinterTo
- type Sequence
- type SignalError
- type TLSConfigOptions
- type TerminalSize
- type TimeoutError
- type ValueError
- type Verbosity
- type WSInteractiveMode
- type WSMessageMode
- type WarningWriter
Constants ¶
const ( MaxArticleBodyBytes int64 = 16 << 20 MaxReadabilityElements = 500_000 MaxHARRequestBodyBytes int64 = 16 << 20 MaxHARResponseBodyBytes int64 = 16 << 20 MaxWebSocketMessageBytes int64 = 16 << 20 MaxWebSocketPipedTextLine int64 = 16 << 20 MaxWebSocketInteractiveEntry int64 = 16 << 20 MaxStreamingRecordBytes int64 = 16 << 20 MaxCompositeMaterialization int64 = 16 << 20 MaxGRPCMessageBytes int64 = 64 << 20 MaxReflectionMessages = 128 MaxReflectionBytes int64 = 64 << 20 MaxProtobufDescriptorSetBytes int64 = 64 << 20 MaxProtocOutputBytes int64 = 64 << 10 MaxNestingDepth = 128 MaxClipboardBytes int64 = 1 << 20 MaxFormatterNestingDepth = 1024 MaxDOHWireResponseBytes int64 = 65_535 MaxDOHJSONResponseBytes int64 = 1 << 20 MaxUpdaterReleaseMetadata int64 = 1 << 20 MaxUpdaterChecksumSidecar int64 = 1 << 10 MaxUpdaterArtifact int64 = 128 << 20 MaxUpdaterUnpackedData int64 = 512 << 20 MaxUpdaterArchiveEntries = 128 MaxDryRunBodyPreview int64 = 1_024 MaxRetries = 100 MaxRetryAfter = 30 * time.Second MaxUpdateRedirects = 10 DefaultDOHTimeout = 5 * time.Second DefaultProtocTimeout = 10 * time.Second )
Shared resource limits. Keep feature-specific limits here so callers and tests use the same security boundary instead of duplicating constants.
const ( // MaxFormattedBodyBytes is the existing cap for complete response // formatting and clipboard capture. MaxFormattedBodyBytes = 1 << 20 // Schema-less protobuf has no descriptor to provide structural bounds. // Keep recursive interpretation and aggregate field work bounded even when // the caller supplies a large protocol message. MaxSchemaLessProtobufFields = 1_000_000 // Descriptive aliases keep call sites self-documenting while preserving // one canonical value for each limit. MaxCompositeMaterializationBytes = MaxCompositeMaterialization MaxUpdaterReleaseMetadataBytes = MaxUpdaterReleaseMetadata MaxUpdaterChecksumSidecarBytes = MaxUpdaterChecksumSidecar MaxUpdaterArtifactBytes = MaxUpdaterArtifact MaxUpdaterUnpackedDataBytes = MaxUpdaterUnpackedData MaxDryRunBodyPreviewBytes = MaxDryRunBodyPreview )
const InterruptedExitCode = 130
Variables ¶
var ( IsStdinTerm bool IsStderrTerm bool IsStdoutTerm bool NoSelfUpdate bool PackageManager string UserAgent string Version string )
var ErrLimitExceeded = errors.New("resource limit exceeded")
ErrLimitExceeded identifies an input that exceeded a bounded operation.
Functions ¶
func AppendTerminalSafeBytes ¶ added in v0.28.0
AppendTerminalSafeBytes appends src after escaping terminal control characters and invalid UTF-8. Newlines and tabs are retained. The destination can be reused by callers that sanitize a stream repeatedly.
func BuildTLSConfig ¶ added in v0.28.0
func BuildTLSConfig(options TLSConfigOptions) *tls.Config
BuildTLSConfig builds an independent TLS configuration using the platform verifier by default. Custom roots are added to, rather than substituted for, the system roots. The returned configuration can be used as a template and must be cloned before a connection-specific mutation.
func CheckedAddInt ¶ added in v0.28.0
CheckedAddInt returns false when a+b would overflow int.
func CheckedAddInt64 ¶ added in v0.28.0
CheckedAddInt64 returns false when a+b would overflow int64.
func CheckedAddUint64 ¶ added in v0.28.0
CheckedAddUint64 returns false when a+b would overflow uint64.
func CheckedInt64ToInt ¶ added in v0.28.0
CheckedInt64ToInt converts v only when it is representable as int.
func CheckedInt64ToUint64 ¶ added in v0.28.0
CheckedInt64ToUint64 converts v only when it is non-negative.
func CheckedIntToInt64 ¶ added in v0.28.0
CheckedIntToInt64 converts v only on platforms where int fits in int64.
func CheckedIntToUint64 ¶ added in v0.28.0
CheckedIntToUint64 converts v only when it is non-negative.
func CheckedMulInt ¶ added in v0.28.0
CheckedMulInt returns false when a*b would overflow int. Negative values are accepted so callers can use this helper for general size arithmetic.
func CheckedUint64ToInt ¶ added in v0.28.0
CheckedUint64ToInt converts v only when it is representable as int.
func CheckedUint64ToInt64 ¶ added in v0.28.0
CheckedUint64ToInt64 converts v only when it is representable as int64.
func CutTrimmed ¶ added in v0.20.0
CutTrimmed splits s around the first instance of sep, returning the trimmed text before and after sep.
func DetectContentType ¶ added in v0.14.0
func GetBuildInfo ¶
GetBuildInfo returns JSON encoded build information for the executable. Dependencies are included only when verbose is true. The variadic argument preserves the old internal call form while allowing metadata commands to match the concise and verbose build-info modes.
func GetTerminalCols ¶ added in v0.16.0
func GetTerminalCols() int
GetTerminalCols returns the number of columns in the terminal, or 0 if unavailable.
func GetVCSRevision ¶ added in v0.19.0
func GetVCSRevision() string
GetVCSRevision returns the git commit hash from Go's embedded build info.
func IsBrokenPipe ¶ added in v0.28.0
IsBrokenPipe reports whether an output operation failed because its reader closed the pipe. Callers should treat this as successful early termination.
func IsSensitiveHeader ¶ added in v0.28.0
IsSensitiveHeader reports whether a header contains a credential or session value that must not be printed in diagnostics. In addition to the standard credential headers, a component-aware classifier covers user-defined names such as X-API-Key and X-ClientSecret without treating X-KeyboardLayout as a credential header merely because it contains the letters "key".
func IsSensitiveQueryKey ¶ added in v0.28.0
IsSensitiveQueryKey reports whether a query key is likely to contain a credential. Matching is case-insensitive and covers compound names such as api_key, access_token, clientSecret, and request-signature.
func JoinIPHostPort ¶ added in v0.28.0
JoinIPHostPort formats an IP address without discarding its IPv6 zone.
func LimitedReader ¶ added in v0.28.0
LimitedReader returns a reader that permits at most max bytes plus one. The extra byte lets callers distinguish an exact-limit input from an overflow without reading unbounded input.
func NewCancelledError ¶ added in v0.28.0
func NewCategoryError ¶ added in v0.28.0
func NewCategoryError(category ErrorCategory, cause error) error
func NewNetworkError ¶ added in v0.28.0
func NewPartialError ¶ added in v0.28.0
func NewRemoteError ¶ added in v0.28.0
func NewUpdateNoOpError ¶ added in v0.28.0
func NewUsageError ¶ added in v0.28.0
func ParseSeconds ¶ added in v0.28.0
ParseSeconds parses a non-negative number of seconds into a duration. Zero means no timeout. Fractional seconds are truncated to nanoseconds; negative, NaN, infinite, and overflowing values are rejected.
func ReadAllLimited ¶ added in v0.28.0
ReadAllLimited reads up to max bytes and reports a LimitError if one more byte is available. It is intended for explicitly bounded materialization, not ordinary streaming response paths.
func RedactHeaderValue ¶ added in v0.28.0
RedactHeaderValue replaces sensitive header values with a stable marker.
func RedactedErrorText ¶ added in v0.28.0
RedactedErrorText returns a terminal-safe error message with URLs carried by url.Error values redacted. Transport errors commonly include the complete request URL in their Error string, so sanitizing only the request metadata is not sufficient.
func RedactedQuery ¶ added in v0.28.0
RedactedQuery returns a query string with values for sensitive keys replaced while preserving the original key spelling, ordering, duplicate fields, and non-sensitive encoding. The classifier intentionally errs on the side of hiding values when a key contains a credential-related term.
func RedactedURL ¶ added in v0.28.0
RedactedURL returns a terminal-safe URL with userinfo and sensitive query values removed. URL userinfo and query values are authentication sources that must not appear in diagnostics.
func SignalExitCode ¶ added in v0.28.0
SignalExitCode returns the stable process status for a signal cause. Ctrl-C follows the conventional shell status 128+SIGINT; termination signals remain ordinary runtime failures.
func TLSVerificationName ¶ added in v0.28.0
TLSVerificationName returns the certificate-verification name for a host. It removes URL brackets, IPv6 zone identifiers, and a DNS root dot. Go's TLS implementation uses an IP ServerName for SAN verification but omits that IP from the SNI extension.
func TerminalSafeBytes ¶ added in v0.28.0
TerminalSafeBytes returns src when it is already safe, or a sanitized copy otherwise. It is the byte-oriented equivalent of TerminalSafeText.
func TerminalSafeText ¶ added in v0.28.0
TerminalSafeText converts untrusted text into a representation that cannot inject terminal control sequences. Newlines and tabs are retained because they are useful diagnostic layout characters; all other C0/C1 controls and invalid UTF-8 are escaped.
func ValidateECHPolicy ¶ added in v0.28.0
func ValidateECHPolicy(mode ECHMode, httpVersion HTTPVersion, min, max uint16) error
ValidateTLSVersions validates the TLS bounds accepted by fetch. A zero minimum means the secure TLS 1.2 default, and a zero maximum means no cap. ValidateECHPolicy validates the ECH mode before any network operation. The mode is deliberately independent from the TLS handshake implementation so transports cannot silently weaken an explicit policy.
A zero TLS bound means that the caller did not set that bound. In that case ECH may raise the effective minimum to TLS 1.3. An explicit TLS 1.2 bound is a configuration conflict because it permits a handshake that cannot carry ECH.
func ValidateTLSVersions ¶ added in v0.28.0
func WriteErrorMsg ¶ added in v0.7.4
WriteErrorMsg writes the provided error to the printer.
func WriteErrorMsgNoFlush ¶ added in v0.7.4
WriteErrorMsgNoFlush writes the provided error msg to the printer, but does not flush the printer.
func WriteInfoMsg ¶ added in v0.7.4
WriteInfoMsg writes the provided info msg to the printer.
func WriteWarningMsg ¶ added in v0.7.4
WriteWarningMsg writes the provided warning msg to the printer.
func WriteWarningMsgIf ¶ added in v0.28.0
WriteWarningMsgIf writes a warning unless silent mode is enabled.
Types ¶
type BoundedBuffer ¶ added in v0.28.0
type BoundedBuffer struct {
// contains filtered or unexported fields
}
BoundedBuffer is an io.Writer that never retains more than max bytes.
func NewBoundedBuffer ¶ added in v0.28.0
func NewBoundedBuffer(max int64, subsystem string) *BoundedBuffer
func (*BoundedBuffer) Bytes ¶ added in v0.28.0
func (b *BoundedBuffer) Bytes() []byte
func (*BoundedBuffer) Len ¶ added in v0.28.0
func (b *BoundedBuffer) Len() int
func (*BoundedBuffer) Reset ¶ added in v0.28.0
func (b *BoundedBuffer) Reset()
type Budget ¶ added in v0.28.0
type Budget struct {
// contains filtered or unexported fields
}
Budget is an immutable wall-clock budget. A zero duration is unlimited; every finite child operation observes the same absolute deadline.
func NewBudget ¶ added in v0.28.0
NewBudget creates a budget starting at the current wall-clock time.
func NewBudgetAt ¶ added in v0.28.0
NewBudgetAt creates a budget with an injectable start time for deterministic tests. Negative durations are invalid; zero means no deadline.
func NewBudgetFromOptional ¶ added in v0.28.0
NewBudgetFromOptional treats nil as an unlimited budget. It is convenient for configuration fields where absence and an explicit zero both disable a timeout.
func NewBudgetFromOptionalAt ¶ added in v0.28.0
NewBudgetFromOptionalAt is the injectable-clock form of NewBudgetFromOptional.
func (Budget) Check ¶ added in v0.28.0
Check reports a timeout when the budget is exhausted. It is an explicit checkpoint for operations that do not yet derive a context.
func (Budget) Child ¶ added in v0.28.0
func (b Budget) Child(phase string) BudgetChild
Child returns a budget view with the same immutable deadline. The phase is used only when the child derives a context or reports its timeout.
func (Budget) ConnectionTimeoutError ¶ added in v0.28.0
ConnectionTimeoutError returns the connection-scoped form of the budget error while retaining the same absolute deadline.
func (Budget) Deadline ¶ added in v0.28.0
Deadline returns the absolute deadline, if this budget is finite.
func (Budget) Err ¶ added in v0.28.0
Err returns nil while the budget remains available, or its stable timeout error after exhaustion.
func (Budget) ErrAt ¶ added in v0.28.0
ErrAt is Err with an injected clock and optional phase label.
func (Budget) Remaining ¶ added in v0.28.0
Remaining returns the time left and whether the budget is finite. An exhausted finite budget returns zero and true; an unlimited budget returns zero and false.
func (Budget) RemainingAt ¶ added in v0.28.0
RemainingAt is Remaining with an injected clock for deterministic tests.
func (Budget) TimeoutError ¶ added in v0.28.0
TimeoutError returns the stable error for an exhausted budget.
func (Budget) WithConnectionContext ¶ added in v0.28.0
func (b Budget) WithConnectionContext(parent context.Context, phase string) (context.Context, context.CancelFunc)
WithConnectionContext derives a context whose timeout is reported as a connection timeout. It shares the same absolute deadline as WithContext.
func (Budget) WithContext ¶ added in v0.28.0
func (b Budget) WithContext(parent context.Context, phase string) (context.Context, context.CancelFunc)
WithContext derives a cancellable context that observes this budget. If a parent deadline is earlier, it is preserved rather than being reset.
type BudgetChild ¶ added in v0.28.0
type BudgetChild struct {
// contains filtered or unexported fields
}
BudgetChild associates a diagnostic phase with an existing budget without creating a new deadline.
func (BudgetChild) Err ¶ added in v0.28.0
func (c BudgetChild) Err() error
func (BudgetChild) Remaining ¶ added in v0.28.0
func (c BudgetChild) Remaining() (time.Duration, bool)
func (BudgetChild) WithContext ¶ added in v0.28.0
func (c BudgetChild) WithContext(parent context.Context) (context.Context, context.CancelFunc)
type CategoryError ¶ added in v0.28.0
type CategoryError struct {
Category ErrorCategory
Err error
}
CategoryError adds stable classification while preserving the underlying error for errors.Is/errors.As and for useful diagnostics.
func (CategoryError) Error ¶ added in v0.28.0
func (err CategoryError) Error() string
func (CategoryError) Is ¶ added in v0.28.0
func (err CategoryError) Is(target error) bool
func (CategoryError) Unwrap ¶ added in v0.28.0
func (err CategoryError) Unwrap() error
type CompressionMode ¶ added in v0.28.0
type CompressionMode int
CompressionMode controls request content-encoding negotiation and response decoding. Unknown means no explicit setting was supplied.
const ( CompressionUnknown CompressionMode = iota CompressionAuto CompressionBrotli CompressionGzip CompressionZstd CompressionOff )
type ECHMode ¶ added in v0.28.0
type ECHMode int
ECHMode controls Encrypted ClientHello discovery and use.
type ErrConnectionTimedOut ¶ added in v0.28.0
ErrConnectionTimedOut represents an exhausted connection-establishment budget. It intentionally has a separate top-level message from request body/response timeouts.
func (ErrConnectionTimedOut) Error ¶ added in v0.28.0
func (err ErrConnectionTimedOut) Error() string
type ErrRequestTimedOut ¶
ErrRequestTimedOut represents the error when the request times out.
func (ErrRequestTimedOut) Error ¶
func (err ErrRequestTimedOut) Error() string
type ErrorCategory ¶ added in v0.28.0
type ErrorCategory uint8
ErrorCategory identifies the stable class of an operation failure.
const ( CategoryUnknown ErrorCategory = iota CategoryUsage CategoryNetwork CategoryRemote CategoryPartial CategoryCancelled CategoryUpdateNoOp )
func CategoryOf ¶ added in v0.28.0
func CategoryOf(err error) ErrorCategory
func (ErrorCategory) String ¶ added in v0.28.0
func (category ErrorCategory) String() string
type FileNotExistsError ¶ added in v0.11.0
type FileNotExistsError string
func (FileNotExistsError) Error ¶ added in v0.11.0
func (err FileNotExistsError) Error() string
func (FileNotExistsError) PrintTo ¶ added in v0.11.0
func (err FileNotExistsError) PrintTo(p *Printer)
type HTTPVersion ¶
type HTTPVersion int
HTTPVersion represents the options for the maximum allowed HTTP version.
const ( HTTPDefault HTTPVersion = iota HTTP1 HTTP2 HTTP3 )
func (HTTPVersion) String ¶ added in v0.19.0
func (v HTTPVersion) String() string
String returns the HTTP version string (e.g. "HTTP/1.1").
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle represents a handle for stderr and stdout Printers.
type ImageSetting ¶ added in v0.8.0
type ImageSetting int
ImageSetting represents the options for displaying images.
const ( ImageUnknown ImageSetting = iota ImageAuto ImageNative ImageExternal ImageOff )
type LimitError ¶ added in v0.28.0
LimitError reports a bounded operation that exceeded its configured limit. The subsystem is included in the message so a user can identify which operation needs a smaller input or a streaming path.
func (LimitError) Error ¶ added in v0.28.0
func (err LimitError) Error() string
func (LimitError) Unwrap ¶ added in v0.28.0
func (err LimitError) Unwrap() error
type PagerMode ¶ added in v0.28.0
type PagerMode int
PagerMode controls whether formatted terminal output may use a pager.
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 TestPrinter ¶ added in v0.20.0
TestPrinter returns a Printer suitable for testing. All output, including flushed data, is captured and accessible via Bytes.
func TestTerminalPrinter ¶ added in v0.28.0
TestTerminalPrinter returns a Printer that behaves like a terminal. It is useful for testing terminal-only presentation such as OSC 8 hyperlinks.
func (*Printer) Bytes ¶
Bytes returns the current contents of the buffer. For test printers created with TestPrinter, this also includes previously flushed data.
func (*Printer) Discard ¶ added in v0.19.0
func (p *Printer) Discard()
Discard clears the buffer without writing to the underlying file. A bounded printer also starts a new bounded transaction.
func (*Printer) EndHyperlink ¶ added in v0.28.0
func (p *Printer) EndHyperlink()
EndHyperlink closes the most recently started OSC 8 terminal hyperlink.
func (*Printer) Err ¶ added in v0.28.0
Err returns the first limit error recorded by a bounded printer.
func (*Printer) IsTerminal ¶ added in v0.28.0
IsTerminal reports whether this printer targets a terminal. Formatting code can use this to select presentation that should not appear in pipes or files.
func (*Printer) NewBoundedWriter ¶ added in v0.28.0
NewBoundedWriter returns a printer that accepts at most max bytes in total. Writes after the limit are discarded and Err reports the limit error. It is useful for formatters that must materialize output before appending it atomically to another printer.
func (*Printer) NewWriter ¶ added in v0.28.0
NewWriter returns a printer with the same color policy as p and a different output writer. It is useful for streaming formatters that must write through an intermediate sink, such as a pager, without buffering the response.
func (*Printer) StartHyperlink ¶ added in v0.28.0
StartHyperlink begins an OSC 8 terminal hyperlink for url. It returns true when a hyperlink was emitted. URLs containing terminal controls are rejected so untrusted Markdown cannot inject an OSC sequence.
func (*Printer) WriteInfoPrefix ¶ added in v0.19.0
func (p *Printer) WriteInfoPrefix()
WriteInfoPrefix writes a dim "* " prefix for informational lines.
func (*Printer) WriteRequestPrefix ¶ added in v0.19.0
func (p *Printer) WriteRequestPrefix()
WriteRequestPrefix writes a dim "> " prefix for request lines.
func (*Printer) WriteResponsePrefix ¶ added in v0.19.0
func (p *Printer) WriteResponsePrefix()
WriteResponsePrefix writes a dim "< " prefix for response lines.
func (*Printer) WriteString ¶
WriteString writes trusted string data to the buffer.
func (*Printer) WriteStringUntrusted ¶ added in v0.28.0
WriteStringUntrusted writes a string after escaping terminal control characters. Newlines and tabs are retained.
type PrinterTo ¶
type PrinterTo interface {
PrintTo(*Printer)
}
PrinterTo represents the interface for printing to a Printer.
type SignalError ¶
type SignalError string
SignalError represents the error when a signal is caught.
func (SignalError) Error ¶
func (err SignalError) Error() string
type TLSConfigOptions ¶ added in v0.28.0
type TLSConfigOptions struct {
Base *tls.Config
CACerts []*x509.Certificate
ClientCert *tls.Certificate
Insecure bool
TLSMax uint16
TLSMin uint16
ServerName string
NextProtos []string
}
TLSConfigOptions contains the settings shared by every TLS client in fetch. Base is cloned before any option is applied, so callers can safely reuse the returned configuration as a template for a connection.
type TerminalSize ¶ added in v0.16.0
type TerminalSize struct {
Cols int // Number of columns (characters)
Rows int // Number of rows (characters)
WidthPx int // Width in pixels (0 if unavailable)
HeightPx int // Height in pixels (0 if unavailable)
}
TerminalSize represents the dimensions of the terminal.
func GetTerminalSize ¶ added in v0.16.0
func GetTerminalSize() (TerminalSize, error)
GetTerminalSize returns the terminal size, or an error if unavailable.
type TimeoutError ¶ added in v0.28.0
TimeoutError is the common budget timeout error. It unwraps to the legacy timeout type so existing retry and presentation code remains compatible.
func (TimeoutError) Error ¶ added in v0.28.0
func (err TimeoutError) Error() string
func (TimeoutError) Temporary ¶ added in v0.28.0
func (err TimeoutError) Temporary() bool
func (TimeoutError) Timeout ¶ added in v0.28.0
func (err TimeoutError) Timeout() bool
func (TimeoutError) Unwrap ¶ added in v0.28.0
func (err TimeoutError) Unwrap() error
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 WSInteractiveMode ¶ added in v0.23.1
type WSInteractiveMode int
WSInteractiveMode represents WebSocket terminal prompt behavior.
const ( WSInteractiveAuto WSInteractiveMode = iota WSInteractiveOn WSInteractiveOff )
type WSMessageMode ¶ added in v0.28.0
type WSMessageMode int
WSMessageMode controls how WebSocket payloads are interpreted.
const ( WSMessageAuto WSMessageMode = iota WSMessageText WSMessageBinary )
func (WSMessageMode) String ¶ added in v0.28.0
func (m WSMessageMode) String() string
String returns the user-facing WebSocket message mode name.
type WarningWriter ¶ added in v0.28.0
type WarningWriter struct {
// contains filtered or unexported fields
}
WarningWriter is the shared warning path for operations that may emit warnings alongside streamed output. It suppresses nonessential warnings in silent mode and guarantees one trailing newline per warning.
func NewWarningWriter ¶ added in v0.28.0
func NewWarningWriter(p *Printer, silent bool) *WarningWriter
NewWarningWriter creates a warning writer for p.
func (*WarningWriter) AfterBody ¶ added in v0.28.0
func (w *WarningWriter) AfterBody() error
AfterBody terminates a body line before a following warning or diagnostic.
func (*WarningWriter) BeforeBody ¶ added in v0.28.0
func (w *WarningWriter) BeforeBody() error
BeforeBody separates diagnostics from body output when both are written to the same presentation stream.
func (*WarningWriter) Write ¶ added in v0.28.0
func (w *WarningWriter) Write(msg string) error
Write emits a terminal-safe warning unless silent mode is enabled.