在golang中没有时间处理日期的惯用方式是什么?

I'm writing a REST API in Go, working with dates that don't represent a single point in time.

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.

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.:

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 -> 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)
}

And then other structs can be of this type, and get 90% there to representing the date type in my problem domain.

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:

Do you think this code will cause more pain than it'll save?
If so, what style would you recommend?

I think you can store your data as time.Time but convert it to a string for JSON purposes:

type LocalDate struct {
  t time.Time `json:",string"` // might even work anonymously here
}

To see how to make this work with SQL: https://github.com/go-sql-driver/mysql#timetime-support