2025-04-01 10:38:02 +09:00

14 lines
221 B
Go

package ctxkey
import "context"
type Key struct{}
func Set(ctx context.Context, data any) context.Context {
return context.WithValue(ctx, Key{}, data)
}
func Get(ctx context.Context) any {
return ctx.Value(Key{})
}