From e376de6f660d3a51bda2c4a17d9d14e85d596154 Mon Sep 17 00:00:00 2001 From: FMotalleb Date: Sat, 6 Jul 2024 17:06:16 +0330 Subject: [PATCH] fix: unified GlobalContext receiver name --- core/global/global_context.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/global/global_context.go b/core/global/global_context.go index 4e436cb..6156313 100644 --- a/core/global/global_context.go +++ b/core/global/global_context.go @@ -12,10 +12,10 @@ import ( ) func CTX() *GlobalContext { - return ctx + return c } -var ctx = newGlobalContext() +var c = newGlobalContext() type ( EventListenerMap = map[string][]func() @@ -41,15 +41,15 @@ func newGlobalContext() *GlobalContext { return ctx } -func (ctx *GlobalContext) EventListeners() EventListenerMap { - listeners := ctx.Value(ctxutils.EventListeners) +func (c *GlobalContext) EventListeners() EventListenerMap { + listeners := c.Value(ctxutils.EventListeners) return listeners.(EventListenerMap) } -func (ctx *GlobalContext) AddEventListener(event string, listener func()) { - ctx.lock.Lock() - defer ctx.lock.Unlock() - listeners := ctx.EventListeners() +func (c *GlobalContext) AddEventListener(event string, listener func()) { + c.lock.Lock() + defer c.lock.Unlock() + listeners := c.EventListeners() listeners[event] = append(listeners[event], listener) - ctx.Context = context.WithValue(ctx.Context, ctxutils.EventListeners, listeners) + c.Context = context.WithValue(c.Context, ctxutils.EventListeners, listeners) }