output

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package output provides structures and functions to handle command output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lines

type Lines []string

Lines represents a collection of output lines from a command execution.

It is essentially a slice of strings, where each string is a line of output.

func NewLines

func NewLines(lines []string) Lines

NewLines creates and returns a new Lines instance from the provided slice of strings.

Parameters:

  • lines: A slice of strings representing the lines of output.

func (Lines) At

func (l Lines) At(idx int) string

At returns the line at the specified index.

If idx is negative, it is interpreted as an offset from the end of the slice (e.g., -1 refers to the last line, -2 to the second-to-last, etc.). It returns an empty string if there are no lines or if the index is out of bounds.

func (Lines) Empty

func (l Lines) Empty() bool

Empty checks if there are no lines.

func (Lines) First

func (l Lines) First() string

First returns the first line.

It returns an empty string if there are no lines.

func (Lines) Last

func (l Lines) Last() string

Last returns the last line.

It returns an empty string if there are no lines.

func (Lines) Len

func (l Lines) Len() int

Len returns the number of lines.

type Output

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

Output represents the output of a system command execution.

func NewOutput

func NewOutput(stdout []byte) Output

NewOutput creates and returns a new Output instance with the specified standard output.

Parameters:

  • stdout: A byte slice representing the standard output of the command.

func (Output) Bytes

func (o Output) Bytes() []byte

Bytes returns the output as a byte slice.

It returns a copy of the internal byte slice to prevent external modification.

func (Output) Empty

func (o Output) Empty() bool

Empty checks if the output is empty.

func (Output) Len

func (o Output) Len() int

Len returns the length of the output.

func (Output) Lines

func (o Output) Lines() Lines

Lines splits the output into lines and returns them as a Lines instance.

It splits the output string at each newline character.

func (Output) String

func (o Output) String() string

String returns a string representation of the output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL