title: Handling optional boolean values
body: <p>I'm failing to understand how I can work around the problem I'm  experiencing in my own application.</p>
  <p>Imagine this example of a struct that models an incoming request and a function that puts the fields from that request into a database.</p>
  <pre><code>type NewBooleanRequest struct {
      RequiredString string `json:&quot;requiredString&quot;`
      OptionalBoolean bool `json:&quot;maybeBoolean&quot;`
  }
  
  func LogBooleanRequest(req NewBooleanRequest, db *sql.DB) {
      db.Exec(&quot;INSERT INTO log (booleanValue, stringValue) VALUES ($1, $2)&quot;, req.OptionalBoolean, req.RequiredString)
  }
  </code></pre>
  <p>Now this obviously works fine if I know I will be given a value for all fields of my request model, but that's not a common requirement in reality.  How do people generally model &quot;optional&quot; semantics for <code>bool</code> values given that <code>bool</code> has a zero value that is valid in essentially all contexts?</p>