diff --git a/src/cmd/go/internal/cache/prog.go b/src/cmd/go/internal/cache/prog.go index 8d826f0b99b6f..f13a8669b1e62 100644 --- a/src/cmd/go/internal/cache/prog.go +++ b/src/cmd/go/internal/cache/prog.go @@ -129,10 +129,10 @@ type ProgResponse struct { // For Get requests. - Miss bool `json:",omitempty"` // cache miss - OutputID []byte `json:",omitempty"` - Size int64 `json:",omitempty"` // in bytes - Time *time.Time `json:",omitempty"` // an Entry.Time; when the object was added to the docs + Miss bool `json:",omitempty"` // cache miss + OutputID []byte `json:",omitempty"` + Size int64 `json:",omitempty"` // in bytes + Time time.Time `json:",omitzero"` // an Entry.Time; when the object was added to the docs // DiskPath is the absolute path on disk of the ObjectID corresponding // a "get" request's ActionID (on cache hit) or a "put" request's @@ -339,8 +339,8 @@ func (c *ProgCache) Get(a ActionID) (Entry, error) { e := Entry{ Size: res.Size, } - if res.Time != nil { - e.Time = *res.Time + if !res.Time.IsZero() { + e.Time = res.Time } else { e.Time = time.Now() } diff --git a/src/cmd/go/internal/modinfo/info.go b/src/cmd/go/internal/modinfo/info.go index ee73c5e07b7fa..4582e7bbda3c0 100644 --- a/src/cmd/go/internal/modinfo/info.go +++ b/src/cmd/go/internal/modinfo/info.go @@ -19,7 +19,7 @@ type ModulePublic struct { Query string `json:",omitempty"` // version query corresponding to this version Versions []string `json:",omitempty"` // available module versions Replace *ModulePublic `json:",omitempty"` // replaced by this module - Time *time.Time `json:",omitempty"` // time version was created + Time time.Time `json:",omitzero"` // time version was created Update *ModulePublic `json:",omitempty"` // available update (with -u) Main bool `json:",omitempty"` // is this the main module? Indirect bool `json:",omitempty"` // module is only indirectly needed by main module diff --git a/src/cmd/go/internal/modload/build.go b/src/cmd/go/internal/modload/build.go index 6e30afd5247b3..628dcf176ac4d 100644 --- a/src/cmd/go/internal/modload/build.go +++ b/src/cmd/go/internal/modload/build.go @@ -156,7 +156,7 @@ func addUpdate(ctx context.Context, m *modinfo.ModulePublic) { m.Update = &modinfo.ModulePublic{ Path: m.Path, Version: info.Version, - Time: &info.Time, + Time: info.Time, } } } @@ -344,7 +344,7 @@ func moduleInfo(ctx context.Context, rs *Requirements, m module.Version, mode Li m.Error = &modinfo.ModuleError{Err: err.Error()} } else { m.Version = q.Version - m.Time = &q.Time + m.Time = q.Time } } diff --git a/src/cmd/go/internal/modload/query.go b/src/cmd/go/internal/modload/query.go index c4cf55442ba69..663ff3f8dc17a 100644 --- a/src/cmd/go/internal/modload/query.go +++ b/src/cmd/go/internal/modload/query.go @@ -234,8 +234,8 @@ func queryProxy(ctx context.Context, proxy, path, query, current string, allowed Version: old.Version, Origin: old.Origin, } - if old.Time != nil { - info.Time = *old.Time + if !old.Time.IsZero() { + info.Time = old.Time } return info, nil } diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go index ec384b6d9b09d..e879cf3e20650 100644 --- a/src/cmd/go/internal/work/action.go +++ b/src/cmd/go/internal/work/action.go @@ -173,9 +173,9 @@ type actionJSON struct { NeedBuild bool `json:",omitempty"` ActionID string `json:",omitempty"` BuildID string `json:",omitempty"` - TimeReady time.Time `json:",omitempty"` - TimeStart time.Time `json:",omitempty"` - TimeDone time.Time `json:",omitempty"` + TimeReady time.Time `json:",omitzero"` + TimeStart time.Time `json:",omitzero"` + TimeDone time.Time `json:",omitzero"` Cmd []string // `json:",omitempty"` CmdReal time.Duration `json:",omitempty"` diff --git a/src/cmd/internal/test2json/test2json.go b/src/cmd/internal/test2json/test2json.go index f7dfbe69d7725..cdbb38bd53f4a 100644 --- a/src/cmd/internal/test2json/test2json.go +++ b/src/cmd/internal/test2json/test2json.go @@ -29,7 +29,7 @@ const ( // event is the JSON struct we emit. type event struct { - Time *time.Time `json:",omitempty"` + Time time.Time `json:",omitzero"` Action string Package string `json:",omitempty"` Test string `json:",omitempty"` @@ -387,8 +387,7 @@ func (c *Converter) writeOutputEvent(out []byte) { func (c *Converter) writeEvent(e *event) { e.Package = c.pkg if c.mode&Timestamp != 0 { - t := time.Now() - e.Time = &t + e.Time = time.Now() } if e.Test == "" { e.Test = c.testName