TLTR

大部分场景应该使用值传递。

正文

Go 的文档指出

Programs using times should typically store and pass them as values, not pointers. That is, time variables and struct fields should be of type time.Time, not *time.Time. A Time value can be used by multiple goroutines simultaneously.

翻译一下就是

time.Time*time.Timetypicallytypicallytime.Time
time.Time
go build -gcflags="-m"
time.Time
byte size is  1
int32 size is  4
int size is  8
int64 size is  8
float32 size is  4
float64 size is  8
time size is  24

测试程序

package demo_base

import (
    "fmt"
    "testing"
    "time"
    "unsafe"
)

func TestSize(t *testing.T) {
    {
        var x byte = 0
        fmt.Println("byte size is ", unsafe.Sizeof(x))
    }
    {
        var x int32 = 0
        fmt.Println("int32 size is ", unsafe.Sizeof(x))
    }
    {
        var x int = 0
        fmt.Println("int size is ", unsafe.Sizeof(x))
    }
    {
        var x int64 = 0
        fmt.Println("int64 size is ", unsafe.Sizeof(x))
    }
    {
        var x float32 = 0
        fmt.Println("float32 size is ", unsafe.Sizeof(x))
    }
    {
        var x float64 = 0
        fmt.Println("float64 size is ", unsafe.Sizeof(x))
    }
    {
        t := time.Now()
        fmt.Println("time size is ", unsafe.Sizeof(t))
    }
}