uctx

package
v1.28.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: MIT Imports: 2 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UContext

type UContext struct {
	// contains filtered or unexported fields
}

UContext provides a concurrent-safe, app-global key-value store.

Use GetContext() to access the singleton instance from anywhere in your application. Values can be stored and retrieved using any comparable key type.

Example usage:

ctx := uctx.GetContext()
ctx.Set("config", myConfig)
cfg := ctx.Get("config").(*Config)

func GetContext

func GetContext() *UContext

GetContext returns the singleton app-global context instance. This instance is safe for concurrent access and should be used throughout your application to store and retrieve global values.

func (*UContext) Delete

func (g *UContext) Delete(key any)

Delete removes the value associated with the provided key.

func (*UContext) Get

func (g *UContext) Get(key any) any

Get retrieves the value associated with the provided key. Returns nil if the key does not exist.

func (*UContext) MustGet

func (g *UContext) MustGet(key any) any

MustGet retrieves the value for the given key. Panics if the key is not present in the context.

func (*UContext) Set

func (g *UContext) Set(key, value any)

Set stores the given value under the provided key. Overwrites any existing value for that key.

Jump to

Keyboard shortcuts

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