Chromium Code Reviews| Index: impl/memory/context.go |
| diff --git a/impl/memory/context.go b/impl/memory/context.go |
| index 7fc489d4e27b8fb58ebcd3ca925c75f474dfa263..feddfda29bd9a3485ac4c86d9dbe2449c78f09e2 100644 |
| --- a/impl/memory/context.go |
| +++ b/impl/memory/context.go |
| @@ -117,7 +117,7 @@ func Use(c context.Context) context.Context { |
| // |
| // Using this more than once per context.Context will cause a panic. |
| func UseWithAppID(c context.Context, aid string) context.Context { |
| - if c.Value(memContextKey) != nil { |
| + if c.Value(&memContextKey) != nil { |
| panic(errors.New("memory.Use: called twice on the same Context")) |
| } |
| c = memlogger.Use(c) |
| @@ -128,7 +128,7 @@ func UseWithAppID(c context.Context, aid string) context.Context { |
| } |
| memctx := newMemContext(fqAppID) |
| - c = context.WithValue(c, memContextKey, memctx) |
| + c = context.WithValue(c, &memContextKey, memctx) |
| c = useGID(c, func(mod *globalInfoData) { |
| mod.appID = aid |
| mod.fqAppID = fqAppID |
| @@ -137,18 +137,16 @@ func UseWithAppID(c context.Context, aid string) context.Context { |
| } |
| func cur(c context.Context) (*memContext, bool) { |
| - if txn := c.Value(currentTxnKey); txn != nil { |
| + if txn := c.Value(¤tTxnKey); txn != nil { |
| // We are in a Transaction. |
| return txn.(*memContext), true |
| } |
| - return c.Value(memContextKey).(*memContext), false |
| + return c.Value(&memContextKey).(*memContext), false |
| } |
| -type memContextKeyType int |
| - |
| var ( |
| - memContextKey memContextKeyType |
|
dnj
2016/11/11 08:37:53
golint error. This was actually a bug - glad nobod
|
| - currentTxnKey = 1 |
| + memContextKey = "gae:memory:context" |
| + currentTxnKey = "gae:memory:currentTxn" |
| ) |
| // weird stuff |
| @@ -186,7 +184,7 @@ func (d *dsImpl) RunInTransaction(f func(context.Context) error, o *ds.Transacti |
| txnMC.endTxn() |
| }() |
| - if err := f(context.WithValue(d, currentTxnKey, txnMC)); err != nil { |
| + if err := f(context.WithValue(d, ¤tTxnKey, txnMC)); err != nil { |
| return err |
| } |