title: Go: pop from a map
body: <p>Is there an existing function where we can pop a (key,value) pair from a map in GO? I use the word pop instead of remove because a pop would re-arrange the elements after the index where the (key,value) was removed.</p>
  
  <p>As an example the following code:</p>
  
  <pre><code>package main
  
  import "fmt"
  
  func main() {
      mapp := make(map[int]int)
      fmt.Println("before removal:")
  
      for i := 1; i &lt; 7; i++ {
          mapp[i] = i
      }
      fmt.Println(mapp)
      delete(mapp, 2)
      fmt.Println("\nafter the removal:")
      for i := 1; i &lt; 7; i++ {
          fmt.Println(i, mapp[i])
      }
  
  }
  </code></pre>
  
  <p>Produces the following output:</p>
  
  <pre><code>before removal:
  map[1:1 2:2 3:3 4:4 5:5 6:6]
  
  after the removal:
  1 1
  2 0
  3 3
  4 4
  5 5
  6 6
  </code></pre>
  
  <p>We notice that index location 2 is empty. I would like the output to be the following:</p>
  
  <pre><code>before removal:
  map[1:1 2:2 3:3 4:4 5:5 6:6]
  
  after the removal:
  1 1
  2 3
  3 4
  4 5
  5 6
  </code></pre>
  
  <p>Is this functionality already in Go or would I have to implement it?</p>