title: Ternary states for bool in Go struct (JSON tag)
body: <pre><code>type Foo struct {
      ID        string  `json:"id"
      Condition bool    `json:"condition,omitempty"`
  }
  </code></pre>
  
  <p>I would like to json.Marshal the <code>Foo struct</code> above but the Condition field should have three states. For example if I do the JSON marshaling: </p>
  
  <blockquote>
    <p>1)</p>
  
  <pre><code>foo := Foo {
      ID:        "one",
      Condition: true,
  }
  </code></pre>
    
    <p>should turn into json: <code>{id:"one","condition":true}</code></p>
    
    <p>2)</p>
  
  <pre><code>foo := Foo {
      ID:        "two",
      Condition: false,
  }
  </code></pre>
    
    <p>should turn into json: <code>{id:"two","condition":false}</code></p>
    
    <p>3)</p>
  
  <pre><code>foo := Foo {
      ID:        "three",
  }
  </code></pre>
    
    <p>should turn into json: <code>{id:"three"}</code></p>
  </blockquote>
  
  <p>Currently, if I do <code>2)</code>, the marshaled json will be <code>{"id":"two"}</code> instead of  <code>{"id":"two,"condition":false}</code> because the zero value of <code>bool</code> is <code>false</code>.</p>
  
  <p>One solution is to construct my struct to use the type of <code>*bool</code> instead, like this:</p>
  
  <pre><code>type Foo struct {
      ID        string  `json:"id"
      Condition *bool   `json:"condition,omitempty"`
  }
  </code></pre>
  
  <p>Is that the idiomatic way of differentiating between non-existent bool and false bool in Go?</p>