[GODRIVER-2630] Use variable name "ctx" in WithSession/WithTransaction callback funcs Created: 31/Oct/22  Updated: 28/Oct/23  Resolved: 08/Nov/22

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.12.0, 1.12.0-alpha1

Type: Improvement Priority: Unknown
Reporter: Matt Dale Assignee: Matt Dale
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
Documentation Changes: Needed

 Description   

We currently document in the Go Driver Code Example Reference that examples should always use variable name "ctx" for the callback function signatures when using the mongo.WithSession and Session.WithTransaction functions.

The reason for that guideline is that it helps prevent a common error of using the outer context (i.e. the one from outside the callback func that doesn't contain the session/transaction information) instead of the inner context from the callback func. Naming the variable "ctx" shadows the context from outside the callback func, preventing that error (assuming users are using the common "ctx" context variable name).

However, the Go Driver code, Godocs, and example code still uses the "sessCtx" variable name. Update all "sessCtx" variable names to "ctx" to match the Go Driver Code Example Reference doc.



 Comments   
Comment by Githook User [ 08/Nov/22 ]

Author:

{'name': 'Matt Dale', 'email': '9760375+matthewdale@users.noreply.github.com', 'username': 'matthewdale'}

Message: GODRIVER-2630 Rename all instances of sessCtx to ctx and reformat Session documentation. (#1113)

Co-authored-by: Kevin Albertson <kevin.albertson@10gen.com>
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/71831b2d3c558d77609d4bfd012bb9df07b2a582

Generated at Thu Feb 08 08:39:03 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.