comp

package
v0.2.20 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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)

--- Retrieval Helpers --- Get retrieves a component by name from a locator and asserts its type. If no name is provided, the default component is retrieved.

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