Deprecate "NewTagSetFromMap" and "NewTagSetsFromMaps" in tags package

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Works as Designed
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: 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?
    • None
    • None
    • None
    • None
    • None
    • None

      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

            Assignee:
            Matt Dale
            Reporter:
            Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: