From 8c413be4551e312dfdcf6a9fe58fa1210396fc54 Mon Sep 17 00:00:00 2001 From: Rohan Shah Date: Mon, 12 Sep 2016 14:38:00 +0530 Subject: [PATCH] Applying write lock even before nil check --- context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context.go b/context.go index 227a64b6..a5cf041b 100644 --- a/context.go +++ b/context.go @@ -159,10 +159,10 @@ func (c *Context) Error(err error) *Error { // Set is used to store a new key/value pair exclusivelly for this context. // It also lazy initializes c.Keys if it was not used previously. func (c *Context) Set(key string, value interface{}) { + c.KeysLocker.Lock() if c.Keys == nil { c.Keys = make(map[string]interface{}) } - c.KeysLocker.Lock() c.Keys[key] = value c.KeysLocker.Unlock() }