comp

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package comp provides concise generic utility functions for component handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsConfig

func AsConfig[T any](h component.Handle) (*T, error)

AsConfig extracts and asserts the configuration from a handle.

func Get

func Get[T any](ctx context.Context, l component.Locator, name string) (T, error)

Get retrieves a component by name from a locator and asserts its type.

func GetDefault

func GetDefault[T any](ctx context.Context, l component.Locator) (T, error)

GetDefault retrieves the default component from a locator and asserts its type.

func GetMap

func GetMap[T any](ctx context.Context, l component.Locator) (map[string]T, error)

GetMap collects all components from the given locator as a map and asserts their type.

func GetWithFallback

func GetWithFallback[T any](ctx context.Context, l component.Locator, name string) (T, error)

GetWithFallback retrieves a component by name, falling back to the default name if not found.

func GetWithTag

func GetWithTag[T any](ctx context.Context, l component.Locator, tag string) (T, error)

GetWithTag retrieves a component by tag from a locator and asserts its type.

func IsReserved

func IsReserved(s string) bool

IsReserved checks if the metadata string is system-reserved.

func IsValidIdentifier

func IsValidIdentifier(s string) bool

IsValidIdentifier checks if the string is a valid identifier for Category, Scope or Tag.

func Iter

func Iter[T any](ctx context.Context, l component.Locator) iter.Seq2[string, T]

Iter returns a type-safe iterator for components in a locator.

func RequireTyped

func RequireTyped[T any](h component.Handle, purpose string) (T, error)

RequireTyped retrieves a requirement by purpose from a handle and asserts its type.

func ValidateScope

func ValidateScope(l component.Locator, s component.Scope) bool

ValidateScope checks if the scope is valid for the given locator.

Types

This section is empty.

Jump to

Keyboard shortcuts

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