<p dir="auto">by <strong><a href="mailto:richard@bucker.net">richard@bucker.net</a></strong>:</p>
<pre class="notranslate">When using GOLANG's encoding for JSON and the datatype is Time. "omitempty"
does not work. It always emits the default value '0001-01-01 00:00:00 +0000 UTC'. This
is not working as expected(<a href="http://play.golang.org/p/vHLyeMwwTX)" rel="nofollow">http://play.golang.org/p/vHLyeMwwTX)</a>.


type Stuff struct {
  Cloned       time.Time   `json:"cloned,omitempty"`
  Expiration   time.Time   `json:"expiration,omitempty"`
}


What is the expected output?

-I expected the default value of time.Time to be empty. 

What do you see instead?

0001-01-01 00:00:00 +0000 UTC


Which compiler are you using (5g, 6g, 8g, gccgo)?

6

Which operating system are you using?

Win

Which version are you using?  (run 'go version')

go1.0.3

Please provide any additional information below.</pre>
<p dir="auto">It is common to use go/types is as part of a go generate command<br>
or other command line tool to introspect a Go package.</p>
<p dir="auto">The go tool goes to some lengths to ensure that whenever<br>
you operate on a package, it builds the source for that<br>
package into object form before using it, so you don't<br>
end up using symbol information that's out of date with respect<br>
to the source.</p>
<p dir="auto">When using go/types from a command line tool, you<br>
don't have that luxury, and it's not necessarily appropriate<br>
to call "go install" automatically.</p>
<p dir="auto">I believe that a better way would be for the default<br>
importer to use the object file data only if it's newer<br>
than the source files, otherwise fall back to using the<br>
source directly. Or at least it would be nice to have<br>
that option, so that it's easy to make go generate<br>
utilities operate on the up to date code.</p>
<p dir="auto">I hope this could be considered before Go 1.5 as<br>
we won't be able to change this behaviour after then.</p>