有人能告诉我为什么这样有效:
s := time.Hour/73.0
fmt.Println("sleeping: ", s)
time.Sleep(s)
Run Code Online (Sandbox Code Playgroud)
但这失败了:
d := 73.0
s := time.Hour/d
fmt.Println("sleeping: ", s)
time.Sleep(s)
Run Code Online (Sandbox Code Playgroud)
这是错误:
invalid operation: time.Hour / d (mismatched types time.Duration and float64)
Run Code Online (Sandbox Code Playgroud)