ioutil

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package ioutil provides I/O utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogWriter

func LogWriter(log *log.Logger, lvl log.Level) (w io.Writer, done func())

LogWriter builds and returns an io.Writer that writes messages to the given logger. If the logger is nil, a no-op writer is returned.

If prefix is non-empty, it is prepended to each message. The done function must be called when the writer is no longer needed. It will flush any buffered text to the logger.

The returned writer is not thread-safe.

func LogfWriter

func LogfWriter(printf func(string, ...any), prefix string) (io.Writer, func())

LogfWriter builds an io.Writer that writes messages to the given logf-style function.

The function is expected to always add a newline to the end of messages.

func TestOutputWriter

func TestOutputWriter(t TestOutput, prefix string) (w io.Writer)

TestOutputWriter builds and returns an io.Writer that writes messages to the given testing.TB. The returned writer is not thread-safe.

Types

type TestOutput

type TestOutput interface {
	Logf(format string, args ...any)
	Cleanup(f func())
}

TestOutput allows writing to the test log.

Jump to

Keyboard shortcuts

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