ctxutil

package
v0.85.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 1 Imported by: 0

README

ctxutil Package

Small helpers for consistent context.Context handling.

Overview

The ctxutil package centralizes context fallback conventions used across the repository. It currently exposes a single helper, OrBackground, for call sites that accept an optional context and need a non-nil context.Context before invoking context-aware APIs.

Public API

Functions
Function Signature Description
OrBackground func(ctx context.Context) context.Context Returns context.Background() when ctx is nil; otherwise returns ctx unchanged

Usage Examples

ctx := ctxutil.OrBackground(ctx)

Dependencies

External:

  • None beyond the Go standard library (context).

This specification is automatically maintained by the spec-extractor workflow.

Documentation

Overview

Package ctxutil provides small helpers for consistent context.Context handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OrBackground

func OrBackground(ctx context.Context) context.Context

OrBackground centralizes the repo's nil-context fallback convention: it returns context.Background() when ctx is nil, otherwise it returns ctx unchanged. Use this instead of duplicating the inline

if ctx == nil {
    ctx = context.Background()
}

pattern at call sites.

Types

This section is empty.

Jump to

Keyboard shortcuts

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