title: What's the idiomatic way to work with dates without time in golang?
body: <p>I'm writing a REST API in Go, working with dates that don't represent a single point in time.</p>
  
  <p>It's JSON data going to and from the server in "2006-01-02" format, with that data talking to a mysql database using DATE columns.</p>
  
  <p>One thing I've tried is to create a struct that embeds a Time, and implements JSON and SQL conversion interface implementations to be able to correctly interact with the endpoints while still having Time methods available for date math and formatting.  e.g.:</p>
  
  <pre><code>package localdate
  
  import (
      "time"
      "encoding/json"
      "database/sql/driver"
  )
  
  type LocalDate struct {
      time.Time
  }
  
  func NewLocalDate(year int, month time.Month, day int) LocalDate {
      time := time.Date(year, month, day, 0, 0, 0, 0, time.UTC)
      return LocalDate{Time: time}
  }
  
  const LocalDateFormat = "2006-01-02" // yyyy-mm-dd
  
  func (ld *LocalDate) UnmarshalJSON(data []byte) error {
      // parse and set the ld.Time variable
  }
  
  func (ld *LocalDate) MarshalJSON() ([]byte, error) {
      return json.Marshal(ld.Format(LocalDateFormat))
  }
  
  // sql.Scanner implementation to convert a time.Time column to a LocalDate
  func (ld *LocalDate) Scan(value interface{}) error {}
  
  // sql/driver.Valuer implementation to go from LocalDate -&gt; time.Time
  func (ld *LocalDate) Value() (driver.Value, error)  {}
  
  // used to convert a LocalDate into something we can plug into a query
  // we could just use ld.Time, but that would send '2015-01-01 00:00:00 +0000 UTC'
  // instead of '2015-01-01' for the DATE query parameter.  (Which works for mysql, but is officially invalid SQL)
  func (ld *LocalDate) SqlDate() string  {
      return ld.Format(LocalDateFormat)
  }
  </code></pre>
  
  <p>And then other structs can be of this type, and get 90% there to representing the date type in my problem domain.  </p>
  
  <p>The above code works, but I feel like I'm fighting against the Go current.  So a couple questions for the veterans of the language:  </p>
  
  <p>Do you think this code will cause more pain than it'll save?<br>
  If so, what style would you recommend?</p>