title: Type wrapping of non-atomic types in golang
body: <p>I'm new to golang and am trying to understand a code example of type wrapping for the "non-atomic" type time.Time.</p>
  
  <p>The type extension in question is from the Go client for GDAX on github, <a href="https://github.com/preichenberger/go-coinbase-exchange" rel="nofollow noreferrer">go-coinbase-exchange project</a>.</p>
  
  <p>The expected behavior would be for Time variables from the project (coinbase.Time), which are of <code>type Time time.Time</code> (as defined in the project's <a href="https://github.com/preichenberger/go-coinbase-exchange/blob/master/time.go" rel="nofollow noreferrer">time.go</a> file) to behave something like the following example for extending the "atomic" type <code>int</code> (from <a href="http://blog.riff.org/2014_07_19_golang_fun_adding_methods_to_primitive_types" rel="nofollow noreferrer">blog.riff.org</a> in that they might follow a kind of "inheritance" from the base type for functions like Time.format (from <a href="https://golang.org/pkg/time/#Time.Format" rel="nofollow noreferrer">golang's standard implementation of time</a>:</p>
  
  <pre><code>package main
  import "fmt"
  type Int int
  
  func (i Int) Add(j Int) Int {
    return i + j
  }
  
  func main() {
    i := Int(5)
    j := Int(6)
    fmt.Println(i.Add(j))
    fmt.Println(i.Add(j) + 12)
  }
  </code></pre>
  
  <p>But if I modify the code example from the project's <code>List Account Ledger</code> example found in <a href="https://github.com/preichenberger/go-coinbase-exchange/blob/master/README.md" rel="nofollow noreferrer">Readme.md</a> to include a print function which might otherwise give me a human-readable view of the CreatedAt struct variables (as follows), I get a compiler error saying that "type <code>coinbase.Time</code> has no field or method <code>Format</code>":</p>
  
  <pre><code>for _, e := range ledger {
      print("Entry Creation: ")
      fmt.Printf(e.CreatedAt.Format("2006-01-02 15:04:05.999999+00"))
  }
  </code></pre>
  
  <p>The expected behavior inside the <code>for</code> loop would be for it to print the ledger entries in a human-readable format. I can get the contents of the structs, but I'm not really sure how to then use the resulting <code>wall</code>, <code>ext</code> and <code>loc</code> members.</p>
  
  <p>For example, inserting <code>fmt.Printf("%#v", e.CreatedAt)</code> into the <code>for</code> loop gives me a representation of the time that looks something like this:</p>
  
  <p><code>coinbase.Time{wall:0x3015a123, ext:63612345678, loc:(*time.Location)(nil)}
  {806986000 63638738354 &lt;nil&gt;}</code></p>
  
  <p>I can also see that <code>wall</code> is of type <code>uint64</code>, that <code>ext</code> is of type <code>int64</code> and that <code>loc</code> is just GMT/UTC=0 by formatting the variable as a string because <code>fmt.Printf("%s", e.CreatedAt)</code> gives me output which is similar to the following:</p>
  
  <p><code>{%!s(uint64=712345678) %!s(int64=63612345678) %!s(*time.Location=&lt;nil&gt;)}</code></p>
  
  <p>It seems like I'm missing something. I've requested further information through <a href="https://github.com/preichenberger/go-coinbase-exchange/issues/24" rel="nofollow noreferrer">issues tab on github</a>, but maybe this is a nube question. So I'm not sure how quick the response time would be, and I'm interested in the more general case for extending non-atomic types in go.</p>