modules: Use value type for module.Time

Which is in line with how we do it elsewhere.
This commit is contained in:
Bjørn Erik Pedersen 2021-06-27 18:06:52 +02:00
parent 6cd2110ab2
commit 3a6dc6d3f4
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
2 changed files with 7 additions and 6 deletions

View file

@ -147,7 +147,7 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct { return json.Marshal(&struct {
Path string `json:"path"` Path string `json:"path"`
Version string `json:"version"` Version string `json:"version"`
Time *time.Time `json:"time"` Time time.Time `json:"time"`
Owner string `json:"owner"` Owner string `json:"owner"`
Dir string `json:"dir"` Dir string `json:"dir"`
Meta map[string]interface{} `json:"meta"` Meta map[string]interface{} `json:"meta"`
@ -169,7 +169,7 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct { return json.Marshal(&struct {
Path string `json:"path"` Path string `json:"path"`
Version string `json:"version"` Version string `json:"version"`
Time *time.Time `json:"time"` Time time.Time `json:"time"`
Owner string `json:"owner"` Owner string `json:"owner"`
Dir string `json:"dir"` Dir string `json:"dir"`
Mounts []modMount `json:"mounts"` Mounts []modMount `json:"mounts"`

View file

@ -68,7 +68,7 @@ type Module interface {
Version() string Version() string
// Time version was created. // Time version was created.
Time() *time.Time Time() time.Time
// Whether this module's dir is a watch candidate. // Whether this module's dir is a watch candidate.
Watch() bool Watch() bool
@ -159,12 +159,13 @@ func (m *moduleAdapter) Version() string {
return m.gomod.Version return m.gomod.Version
} }
func (m *moduleAdapter) Time() *time.Time { func (m *moduleAdapter) Time() time.Time {
if !m.IsGoMod() || m.gomod.Time == nil { if !m.IsGoMod() || m.gomod.Time == nil {
return nil return time.Time{}
} }
return m.gomod.Time return *m.gomod.Time
} }
func (m *moduleAdapter) Watch() bool { func (m *moduleAdapter) Watch() bool {