Applying write lock even before nil check

This commit is contained in:
Rohan Shah 2016-09-12 14:38:00 +05:30
parent 4db1d0ce36
commit 8c413be455

View File

@ -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()
}