From 57fd6699425bdb97baf6bbeddc3099ffcb4576d8 Mon Sep 17 00:00:00 2001 From: "yong.an" Date: Mon, 13 Jul 2020 14:57:54 +0800 Subject: [PATCH] accept lunny's suggestion --- session.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/session.go b/session.go index 7e8b19cb..709c81f0 100644 --- a/session.go +++ b/session.go @@ -100,17 +100,8 @@ func newSessionID() string { } func newSession(engine *Engine) *Session { - var ctx context.Context - var sessionID string - if engine.logSessionID { - sessionID = newSessionID() - ctx = context.WithValue(engine.defaultContext, log.SessionIDKey, sessionID) - } else { - ctx = engine.defaultContext - } - session := &Session{ - ctx: ctx, + ctx: engine.defaultContext, engine: engine, tx: nil, statement: statements.NewStatement( @@ -139,7 +130,7 @@ func newSession(engine *Engine) *Session { sessionType: engineSession, } if engine.logSessionID { - session.ctx = context.WithValue(session.ctx, sessionID, session) + session.ctx = context.WithValue(session.ctx, log.SessionIDKey, session) } return session }