modules: Use value type for module.Time
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 27 Jun 2021 16:06:52 +0000 (18:06 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 27 Jun 2021 16:06:52 +0000 (18:06 +0200)
Which is in line with how we do it elsewhere.

commands/config.go
modules/module.go

index 2b2920cdd92473d56b1d83ebae8d9d8326d55250..87c8c90d60e3397d7ccee902d9ffd2e91fe7ea6f 100644 (file)
@@ -147,7 +147,7 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
                return json.Marshal(&struct {
                        Path        string                 `json:"path"`
                        Version     string                 `json:"version"`
-                       Time        *time.Time             `json:"time"`
+                       Time        time.Time              `json:"time"`
                        Owner       string                 `json:"owner"`
                        Dir         string                 `json:"dir"`
                        Meta        map[string]interface{} `json:"meta"`
@@ -169,7 +169,7 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
        return json.Marshal(&struct {
                Path    string     `json:"path"`
                Version string     `json:"version"`
-               Time    *time.Time `json:"time"`
+               Time    time.Time  `json:"time"`
                Owner   string     `json:"owner"`
                Dir     string     `json:"dir"`
                Mounts  []modMount `json:"mounts"`
index a6feaab736b86366a23d426ae86e2a35ad3fd62b..0d094fe87f738bbcf3bb64d7ef79b230a398bf3a 100644 (file)
@@ -68,7 +68,7 @@ type Module interface {
        Version() string
 
        // Time version was created.
-       Time() *time.Time
+       Time() time.Time
 
        // Whether this module's dir is a watch candidate.
        Watch() bool
@@ -159,12 +159,13 @@ func (m *moduleAdapter) Version() string {
        return m.gomod.Version
 }
 
-func (m *moduleAdapter) Time() *time.Time {
+func (m *moduleAdapter) Time() time.Time {
        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 {