tls

package
v2.10.45 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 2 Imported by: 1 module, 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 tls provides goroutine-local storage (thread-local storage). Values are keyed by their type and scoped to the current goroutine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear[V any]()

Clear removes the value of the given type from the current goroutine's local storage. If no values remain for the goroutine, the entire store entry is cleaned up.

func Get

func Get[V any]() (V, bool)

Get retrieves a value from the current goroutine's local storage by type. Returns the value and true if found, or the zero value and false otherwise.

func Put

func Put[V any](value V)

Put stores a value in the current goroutine's local storage, keyed by its type. Calling Put multiple times with the same type overwrites the previous value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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