title: How to pretty print the contents of a sync Map
body: <p>I want to pretty print the contents of a sync map in Go. 
  I have a sync.Map <code>data</code> I want to print the contents of it.</p>
  
  <p>To view the value of a specific key <code>SiteData</code> I can run the following code.</p>
  
  <pre><code>var data sync.Map
  siteData := map[string]string{"Name": "StackOverflow"}
  data.Store("SiteData", siteData)
  temp, _ := data.Load("SiteData") 
  b, _ := json.MarshalIndent(temp, "", " ")
  fmt.Println(string(b))
  </code></pre>
  
  <p>But I wish to print the entire map at once. This is because the <code>data</code> can have many keys and I want to print them at once. </p>
  
  <p>Running the below code doesn't work and prints <code>{}</code></p>
  
  <pre><code>var data sync.Map
  siteData := map[string]string{"Name": "StackOverflow"}
  data.Store("SiteData", siteData)
  b, _ := json.MarshalIndent(data, "", " ")
  fmt.Println(string(b))
  </code></pre>