unwrap

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package unwrap finds a concrete driver behind wrapping drivers. Wrappers preserve the original contract in their Unwrap return type; this helper does not use reflection or search arbitrary object graphs.

Example: native, found := unwrap.As[*memorycache.Driver](store.Driver()); fmt.Println(found, native != nil)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As[T any, D any](driver D) (T, bool)

As walks driver and the drivers it wraps, following Unwrap() D, and returns the first one of type T. Failure returns T's zero value and false. Wrappers must form an acyclic chain; a typed nil driver is returned if it matches T, like an ordinary type assertion.

if native, found := unwrap.As[*memorycache.Driver](store.Driver()); found {
	fmt.Println(native != nil)
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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