Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2630

Use variable name "ctx" in WithSession/WithTransaction callback funcs

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.12.0, 1.12.0-alpha1
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Needed

      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.

            Assignee:
            matt.dale@mongodb.com Matt Dale
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: