Help us shape the future of Go! Take the 2026 Go Developer Survey

mocks

package
v0.0.84 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package mocks wraps libopenapi's mock generator with the handling its three failure modes need: it panics on some inputs, it reports an exhausted work budget through a sentinel error rather than a failure, and it can return a payload far larger than a caller wants to embed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SafeGenerate

func SafeGenerate(
	gen *renderer.MockGenerator,
	mockable any,
	label string,
	maxBytes int,
	warn WarnFunc,
) (mock []byte, err error)

SafeGenerate renders mockable, returning nil when the result has to be thrown away. label identifies the subject in any warning.

A zero or negative maxBytes disables the size ceiling.

Types

type WarnFunc

type WarnFunc func(message, context string, err error)

WarnFunc reports a mock that was discarded. Callers decide whether that means logging, collecting a diagnostic, or both.

Jump to

Keyboard shortcuts

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