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 ¶
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) Set ¶
func (c *CustomContext) Set(key, value interface{}) error
Set 设置指定键的值并返回错误
func (*CustomContext) Value ¶
func (c *CustomContext) Value(key interface{}) interface{}
Value 获取指定键的值
Click to show internal directories.
Click to hide internal directories.