csvexport

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package csvexport writes pingtrace results to disk as CSV.

Filenames follow {op}[_TAG]_UTC<YYYY-MM-DD-HH-MM-SS>.csv. When the run is scoped to one or more CIDRs the TAG is the sanitized CIDR list (e.g. ping_10.0.0.0_28_UTC...csv); otherwise the TAG segment is omitted. One file is produced per operation per run; subsequent targets / cycles append rows to the same file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	Operation string
	Path      string
	RowCount  int
}

FileInfo describes one CSV file written during this run.

type Writer

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

Writer holds one or more open CSV files for the lifetime of a run. All public methods are safe for concurrent use; an internal mutex serializes writes so the bulk-mode worker pool can call us from many goroutines without corrupting rows.

func New

func New(dir string) (*Writer, error)

New creates the export directory (if missing) and stamps every filename written through this Writer with the same UTC timestamp.

func (*Writer) Close

func (w *Writer) Close() ([]string, error)

Close flushes and closes every file opened by this writer and returns the list of paths produced (for the final summary line).

func (*Writer) Files

func (w *Writer) Files() []FileInfo

Files returns a snapshot of the files opened so far, along with how many data rows have been written to each (excluding the header). Safe to call after Close to feed `jsonreport.Writer`'s exportedFiles.

func (*Writer) MTRCycle

func (w *Writer) MTRCycle(target string, cycle int, snap probe.MTRResult) error

MTRCycle appends one row per hop for a single MTR cycle.

func (*Writer) Ping

func (w *Writer) Ping(target string, r probe.PingResult) error

Ping writes per-packet rows for one target.

func (*Writer) PingSummary

func (w *Writer) PingSummary(target string, r probe.PingResult) error

PingSummary writes one summary row per target instead of per-packet.

func (*Writer) SetCompact added in v1.1.0

func (w *Writer) SetCompact(v bool)

SetCompact enables compact mode: columns that are entirely empty across all rows of a target are omitted from the CSV output. The column set is locked in on the first write to each file and held for all subsequent targets in the same run.

func (*Writer) SetFromTo added in v1.1.0

func (w *Writer) SetFromTo(src, to string)

SetFromTo sets the source IP and target description used in filenames. When both are non-empty the filename becomes:

<op>_from_<src>_to_<to>_UTC<stamp>.csv

Call before the first write.

func (*Writer) SetTag

func (w *Writer) SetTag(tag string)

SetTag adds a sanitized infix between the operation name and the UTC timestamp in produced filenames (e.g. "10.0.0.0_28" so bulk CIDR runs are easy to spot in a reports/ folder). Pass an empty string to clear.

func (*Writer) Trace

func (w *Writer) Trace(target string, r probe.TraceResult) error

Trace writes per-hop rows for one target.

Jump to

Keyboard shortcuts

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