文档 无静态方法
这里不是静态方法,而是结构体类型的方法?

code
在 Go 中,Time 是一个结构体类型,而 Month() 是其方法。这些方法是实例方法,需要在一个 Time 类型的实例上调用,而不是静态方法。
例如:
package main
import (
"fmt"
"time"
)
func main() {
// 创建一个 Time 实例
now := time.Now()
// 调用 Month 方法获取月份
month := now.Month()
// 将月份转换为字符串
monthName := month.String()
fmt.Println("当前月份是:", monthName)
}
在这个例子中:
time.Now()返回当前时间的Time实例。now.Month()是调用Time实例的Month()方法。month.String()将time.Month类型转换为字符串表示。
这些方法是定义在 Time 类型上的,而不是静态方法。