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

Deprecate "NewTagSetFromMap" and "NewTagSetsFromMaps" in tags package

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Icon: Unknown Unknown
    • None
    • None
    • None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

    Description

      The NewTagSetFromMap and NewTagSetsFromMaps functions may mislead users into expecting that the ordered tag.Set type can be created from a Go map, when in fact the resulting tag.Set has a non-deterministic order. Deprecate those functions in preparation for them to be removed with v2.0.

      Note that users can safely define ordered tag sets using a syntax like

      set := tag.Set{{Name: "name", Value: "value"}, ...}
      

      However, that's a bit verbose for longer tag sets, so we should consider adding a convenience function that takes in a list of tag tuples and creates a Set, returning an error if the list length is odd.

      func ToSet(tags ...string) (Set, error)
      

      Since that requires users to handle errors, and we typically expect users to define this statically in code, we should also consider adding a shorter convenience function that panics on any errors (inspired by Go's template.Must).

      func Must(Set, error) Set
      

      Definition of done:

      • Deprecate NewTagSetFromMap and NewTagSetsFromMaps
      • Consider adding convenience functions for creating a Set

      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: