title: Check if a map is initialised in Golang
body: <p>I'm decoding some JSON into a struct, and I'd like to handle the case where a particular field is not provided.</p>
  
  <p>Struct:</p>
  
  <pre><code>type Config struct {
      SolrHost string
      SolrPort int
      SolrCore string
      Servers  map[string][]int
  }
  </code></pre>
  
  <p>JSON to decode:</p>
  
  <pre><code>{
    "solrHost": "localhost",
    "solrPort": 8380,
    "solrCore": "testcore",
  }
  </code></pre>
  
  <p>In the method that decodes the JSON, I'd like to check if the <code>map[string][]int</code> has been initialised, and if not, do so.</p>
  
  <p>Current code:</p>
  
  <pre><code>func decodeJson(input string, output *Config) error {
      if len(input) == 0 {
          return fmt.Errorf("empty string")
      }
      decoder := json.NewDecoder(strings.NewReader(input))
      err := decoder.Decode(output)
      if err != nil {
          if err != io.EOF {
              return err
          }
      }
  
      // if output.Server.isNotInitialized...
  
      return nil
  }
  </code></pre>
  
  <p>Could I make use of <code>recover()</code>? Is that the "nicest" way to achieve my task?</p>