From 8095996c9504c07ce07b3f56452668f8cea109c4 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 17 Feb 2024 21:34:32 +0800 Subject: [PATCH] Refactor WithGlobal method to handle nil data --- pipe/context.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pipe/context.go b/pipe/context.go index ecf1a308..569d8bc1 100644 --- a/pipe/context.go +++ b/pipe/context.go @@ -321,7 +321,14 @@ func (ctx *Context) With(context context.Context) *Context { // WithGlobal with the global data func (ctx *Context) WithGlobal(data map[string]interface{}) *Context { - ctx.global = data + if data != nil { + if ctx.global == nil { + ctx.global = map[string]interface{}{} + } + for k, v := range data { + ctx.global[k] = v + } + } return ctx }