title: Deep copying maps in Golang
body: <p>From what I understand, maps are reference types in Go. So assignment will do shallow copy. I plan to do a recursive deep copy of Maps in golang. Recursive because I am dealing with a map that holds the unmarshalled contents of a JSON.</p>
  
  <pre><code>func deepCopyJSON(src map[string]interface{}, dest *map[string]interface{}) error {
      if src == nil || dest == nil {
          return errors.New("src/dest is nil. You cannot insert to a nil map")
      }
      for key, value := range src {
          if reflect.TypeOf(value).String() != jsonType {
              (*dest)[key] = value
          } else {
              (*dest)[key] = make(map[string]int)
  //Suspect code below causes the error.
              deepCopyJSON(value.(map[string]interface{}), &amp;(((*dest)[key]).(map[string]interface{})))
          }
      }
      return nil
  }
  </code></pre>
  
  <p>The Error: cannot take the address of (*dest)[key].(map[string]interface {})
  How do I get around this? Are there other ways to deep maps?</p>
  
  <p>I primer on the internals of map in golang, will also be useful.</p>