out

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package out contains simple functions to print messages out and maybe die.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginTabWrite

func BeginTabWrite() *tabwriter.Writer

BeginTabWrite returns a new tabwriter that prints to stdout.

func BeginTabWriteTo

func BeginTabWriteTo(w io.Writer) *tabwriter.Writer

BeginTabWriteTo returns a new tabwriter that prints to w.

func Die

func Die(msg string, args ...interface{})

Die prints a message to stderr and exits with 1.

func DumpJSON

func DumpJSON(j interface{})

DumpJSON prints json to stderr. This exits with 1 if the input is unmarshalable.

func ErrAndMsg

func ErrAndMsg(code int16, msg *string) bool

ErrAndMsg prints OK to stdout if code is 0, otherwise the error name to stderr as well as a message if non-nil.

This returns true if the code was an error.

func Exit

func Exit()

Exit calls os.Exit(1).

func ExitErrJSON

func ExitErrJSON(j interface{}, msg string, args ...interface{})

ExitErrJSON prints a message to stderr, dumps json to stdout, and exits with 1.

func ExitJSON

func ExitJSON(j interface{})

ExitJSON dumps json to stdout and exits with 0.

func MaybeDie

func MaybeDie(err error, msg string, args ...interface{})

MaybeDie, if err is non-nil, prints the message and exits with 1.

func MaybeExitErrMsg

func MaybeExitErrMsg(code int16, msg *string)

Types

type TabWriter added in v0.6.0

type TabWriter struct {
	*tabwriter.Writer
}

TabWriter writes tab delimited output.

func NewTabWriter added in v0.6.0

func NewTabWriter() *TabWriter

NewTabWriter returns a TabWriter. For table formatted output, prefer NewTable. This function is meant to be used when you may want some column style output (i.e., headers on the left).

func NewTable added in v0.6.0

func NewTable(headers ...string) *TabWriter

NewTable returns a TabWriter that is meant to output a "table". The headers are uppercased and immediately printed; Print can be used to append additional rows.

func (*TabWriter) Line added in v0.6.0

func (t *TabWriter) Line(sprint ...interface{})

Line prints a newline in our tab writer. This will reset tab spacing.

func (*TabWriter) Print added in v0.6.0

func (t *TabWriter) Print(args ...interface{})

Print stringifies the arguments and calls PrintStrings.

func (*TabWriter) PrintStrings added in v0.6.0

func (t *TabWriter) PrintStrings(args ...string)

PrintStrings prints the arguments tab-delimited and newline-suffixed to the tab writer.

Jump to

Keyboard shortcuts

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