nils

package
v1.14.4 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package nils provides checks to help avoid panics caused by named functions using empty arguments, or nil pointers.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrArgument    = errors.New("nils: no argument provided")
	ErrBoil        = errors.New("nils: boil context executor is invalid")
	ErrContext     = errors.New("nils: ctx context is invalid")
	ErrEchoHandler = errors.New("nils: echo handler func is invalid")
	ErrEchoRoutes  = errors.New("nils: echo routes is invalid")
	ErrEmbedFS     = errors.New("nils: embed file system instance is invalid")
	ErrFS          = errors.New("nils: file system instance is invalid")

	ErrBytesBuf     = errors.New("bytes buffer pointer is nil")
	ErrEchoContext  = errors.New("echo context pointer is nil")
	ErrEchoEcho     = errors.New("echo echo pointer is nil") //nolint:dupword
	ErrEchoGroup    = errors.New("echo group pointer is nil")
	ErrFileHeader   = errors.New("multipart file header pointer is nil")
	ErrModels       = errors.New("models file pointer is nil")
	ErrModelSummary = errors.New("model summary pointer is nil")
	ErrSQLDB        = errors.New("sql db database pointer is nil")
	ErrSQLTx        = errors.New("sql tx transaction pointer is nil")
	ErrSlogLogger   = errors.New("slog logger pointer is nil")

	ErrPointer = errors.New("pointer is nil")
)

Functions

func BoilExec

func BoilExec(exec boil.ContextExecutor) bool

BoilExec returns true if the database boil package, context executor is invalid.

func BoilExecCrash

func BoilExecCrash(exec boil.ContextExecutor)

BoilExecCrash panics if the database boil package, context extractor is invalid. This is a lazy fallback function intended for the model packages to reduce programming boilerplate, however its use should generally be avoided.

func Check

func Check(args ...any) error

Check looks for any nil pointers or values and returns an error if found. This is intended for the arguments of named functions and methods. And importantly to avoid unexpected panics caused by nil pointers.

func IsNil

func IsNil(v any) bool

IsNil reports whether v is nil or a typed nil.

func Slog

func Slog(msg string, args ...any) bool

Slog looks for any nil pointers or values, and if found, logs an error using the [log.slog] package. This is intended for the arguments of named functions and methods that do not return errors.

False is returned when all the args are valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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