contextx

package
v0.11.11 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-08 20:22:05 * @FilePath: \go-toolbox\pkg\contextx\context.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCustomContext

func IsCustomContext(ctx context.Context) bool

IsCustomContext 检查上下文是否是 CustomContext

Types

type CustomContext

type CustomContext struct {
	Tags map[interface{}]interface{}
	context.Context
	// contains filtered or unexported fields
}

CustomContext 是一个自定义的上下文,支持多个值的存储

func NewContextWithValue

func NewContextWithValue(parent context.Context, key, val interface{}, pool *osx.LimitedPool) (*CustomContext, error)

NewContextWithValue 在父上下文中设置值并返回新的 CustomContext

func NewCustomContext

func NewCustomContext(parent context.Context, pool *osx.LimitedPool) *CustomContext

NewCustomContext 创建一个新的 CustomContext,允许用户传入自定义的字节切片池

func NewLocalContextWithValue

func NewLocalContextWithValue(ctx *CustomContext, key, val interface{}) (*CustomContext, error)

NewLocalContextWithValue 在当前 CustomContext 中设置局部值

func (*CustomContext) Remove

func (c *CustomContext) Remove(key interface{})

Remove 删除指定键的键值对

func (*CustomContext) Set

func (c *CustomContext) Set(key, value interface{}) error

Set 设置指定键的值并返回错误

func (*CustomContext) String

func (c *CustomContext) String() string

String 返回上下文的字符串表示

func (*CustomContext) Value

func (c *CustomContext) Value(key interface{}) interface{}

Value 获取指定键的值

Jump to

Keyboard shortcuts

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