output

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package output renders per-host scan results in one of several formats. Writers are streaming: the scanner calls WriteHost as each host result arrives, and End flushes any trailer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableVT

func EnableVT()

EnableVT is a no-op on non-Windows systems.

func Service

func Service(port uint16) string

Service returns a best-guess canonical service name for the given TCP port, or "" if the port is not in the IANA registry.

func ShouldColor

func ShouldColor(w io.Writer, forceOn, forceOff bool) bool

ShouldColor decides whether ANSI styling should be used for w.

  • forced true → always on.
  • forced false → always off.
  • auto → on when w is an *os.File pointing at a TTY AND NO_COLOR is not set. https://no-color.org/

Types

type Format

type Format string

Format selects the renderer.

const (
	FormatHuman Format = "human"
	FormatJSON  Format = "json"
	FormatGrep  Format = "grep"
	// FormatLive is selected by --live; the CLI downgrades to
	// FormatHuman automatically when stdout isn't a TTY so pipelines
	// stay clean.
	FormatLive Format = "live"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat maps a user string to a Format.

type Options

type Options struct {
	// Color enables ANSI styling in the human writer. Ignored by json/grep.
	Color bool
	// Verbose is 0 (open only), 1 (+ closed/filtered), 2 (+ errors).
	Verbose int
}

Options tunes writer rendering.

type Writer

type Writer interface {
	// Begin is called once before any WriteHost. Implementations may
	// emit a header or set up state.
	Begin() error
	// WriteHost renders a single host's result.
	WriteHost(hr portscan.HostResult) error
	// End is called once after the last WriteHost. Use it to flush
	// trailers (e.g., a summary line).
	End() error
}

Writer is the streaming output interface.

func New

func New(format Format, w io.Writer, opts Options) Writer

New returns a Writer for the selected format.

Jump to

Keyboard shortcuts

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