dump

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dump lays out the data an action returned, such as the request and the response of a step, as YAML-like lines to be read by a person:

headers:
  Accept: */*
method: GET
url: https://example.com/

It is meant for reading, not for parsing back:

  • The keys of a map are sorted, so the same data is always laid out the same way.
  • A string of several lines is written under its key, as a YAML block, and each of its lines is indented there. So is a line that ends in a newline, as a body often does, so that its quotes are not escaped.
  • A string of one line is quoted, as Go quotes it, when it could be read as something else: when it is empty, looks like a number, true, false or null, has a space at either end, or holds a control character, such as a newline that is all it holds. A control character is never written as it is, in a key either, so that it cannot move the cursor of a terminal.
  • A block is written after |, as YAML writes it, when the string ends in a newline, and after |- when it does not.
  • A string that is not UTF-8, or a []byte, is not written at all, only how many bytes it holds, as binary data is no use on a terminal.

Options can cut what is long, and say how much was cut, so that a large response body cannot bury what it is shown with.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lines

func Lines(m map[string]any, o Options) []string

Lines lays out m as YAML-like lines, without a newline at their end. The lines of an entry nested in another are indented by two spaces for each level; the entries of m itself are not indented.

Types

type Options

type Options struct {
	// MaxBytes is how many bytes of a string are shown, or 0 for all of them.
	MaxBytes int
	// MaxLines is how many lines of a string are shown, or 0 for all of them.
	MaxLines int
	// MaxItems is how many entries of a map or a list are shown, or 0 for all
	// of them.
	MaxItems int
	// OmitEmpty leaves out the entries of the map given to Lines whose value
	// is nil, an empty string or an empty map or list, such as the empty
	// fields every action fills in. A zero or a false is kept, as it is a
	// value a test may have read. The maps nested in it are laid out whole:
	// what they hold is the data, such as a body or a row, empty values and
	// all.
	OmitEmpty bool
}

Options say what is cut and left out. The zero value lays out everything.

Jump to

Keyboard shortcuts

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