gctx

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 7 Imported by: 490

Documentation

Overview

Package gctx wraps context.Context and provides extra context features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxId

func CtxId(ctx context.Context) string

CtxId retrieves and returns the context id from context.

func GetInitCtx added in v2.1.3

func GetInitCtx() context.Context

GetInitCtx returns the initialization context. Initialization context is used in `main` or `init` functions.

func NeverDone added in v2.5.1

func NeverDone(ctx context.Context) context.Context

NeverDone wraps and returns a new context object that will be never done, which forbids the context manually done, to make the context can be propagated to asynchronous goroutines.

func New

func New() context.Context

New creates and returns a context which contains context id.

func SetInitCtx added in v2.1.3

func SetInitCtx(ctx context.Context)

SetInitCtx sets custom initialization context. Note that this function cannot be called in multiple goroutines.

func WithCtx

func WithCtx(ctx context.Context) context.Context

WithCtx creates and returns a context containing context id upon given parent context `ctx`.

Types

type Ctx

type Ctx = context.Context // Ctx is short name alias for context.Context.

type StrKey

type StrKey string // StrKey is a type for warps basic type string as context key.

Jump to

Keyboard shortcuts

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