title: Golang JSON Marshal/Unmarshal postgres now()
body: <p>I'm using postgres' <code>now()</code> as a default for my <code>created</code> timestamp, which is generates this:</p>
  
  <pre><code> id | user_id | title | slug | content |          created           
  ----+---------+-------+------+---------+----------------------------
    1 |       1 | Foo   | foo  | bar     | 2014-12-16 19:41:31.428883
    2 |       1 | Bar   | bar  | whiz    | 2014-12-17 02:03:31.566419
  </code></pre>
  
  <p>I tried to use <code>json.Marshal</code> and <code>json.Unmarshal</code> and ended up getting this error:</p>
  
  <p><code>parsing time ""2014-12-16 19:41:31.428883"" as ""2006-01-02T15:04:05Z07:00"": cannot parse " 19:41:31.428883"" as "T"</code></p>
  
  <p>So I decided to try and create a custom time, but can't seem to get anything working.</p>
  
  <h3>Post.go</h3>
  
  <pre><code>package models
  
  type Post struct {
      Id      int    `json:"id"`
      UserId  int    `json:"user_id"`
      Title   string `json:"title"`
      Slug    string `json:"slug"`
      Content string `json:"content"`
      Created Tick   `json:"created"`
      User    User   `json:"user"`
  }
  </code></pre>
  
  <h3>Tick.go</h3>
  
  <pre><code>package models
  
  import (
      "fmt"
      "time"
  )
  
  type Tick struct {
      time.Time
  }
  
  var format = "2006-01-02T15:04:05.999999-07:00"
  
  func (t *Tick) MarshalJSON() ([]byte, error) {
      return []byte(t.Time.Format(format)), nil
  }
  
  func (t *Tick) UnmarshalJSON(b []byte) (err error) {
      b = b[1 : len(b)-1]
      t.Time, err = time.Parse(format, string(b))
      return
  }
  </code></pre>
  
  <p>Any help would be much appreciated, running what I've wrote here gives me this:</p>
  
  <p><code>json: error calling MarshalJSON for type models.Tick: invalid character '0' after top-level value</code></p>