title: Using variable-length array as a map key in golang
body: <p>I can't find a good way to do this. I want to have a map from a list of sorted key-value pairs.</p>
  
  <pre><code>type Tag struct {
    key   string
    value string
  }
  
  type SortedTag []Tag // sorted list of tags.
  map[SortedTags]T // cannot do.
  </code></pre>
  
  <p>I can solve this problem by joining all the key-value pairs with a delimiter, but I feel like this is inefficient and error prone in many ways. Converting back to the key-value pair is cumbersome because we need to split the input. moreover, if the key value pair can be anything, that means we have to escape it.</p>
  
  <p>If it was python, I would've stored <code>Tag</code> as N-tuple of sorted 2-tupless.</p>
  
  <p>If it was java, I would've created a composite object with <code>Map&lt;String,String&gt;</code> with <code>equals()</code> checking against the other hash map, <code>hashCode()</code> returning the <code>xor</code> of all the hashes of the map (<code>xor</code> since it is commutative thus we can iterate the map in any order to compute this value).</p>
  
  <p>In go, I can't think of any other good way.</p>