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

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

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Unknown Unknown
    • 1.12.0, 1.12.0-alpha1
    • None
    • None
    • None
    • 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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: