go - 比较时间的分钟数。持续时间?

标签 go

比较 2 个 time.Duration 值与 math.Min 错误:

cannot use someTime (type time.Duration) as type float64 in argument to math.Min

我可以使用 if else 语句来获取最短持续时间,但是是否有用于获取最短持续时间的 native min 函数?

最佳答案

标准库里没有,自己写也简单。

func minDuration(a, b time.Duration) time.Duration {
    if a <= b { return a }
    return b
}

关于go - 比较时间的分钟数。持续时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34301784/

相关文章:

go - 代理处理函数中 []byte 的字符串表示形式

go - 由于 "Authentication failed: EOF",Mesos 框架保持不活动状态

go - Gomplate : bad character U+0022 '-'

arrays - 将 [32]byte 转换为 [8]uint32

google-app-engine - 在没有 http.Redirect 的情况下实现 OAuth2 Facebook 登录

go - x509 CheckSignature 参数

javascript - POST 请求在 beego 框架上被视为 OPTIONS

json - 戈朗 : Read non valid JSON from text file

go - 解析嵌套的 JSON 字符串

go - 从文件中读取字节到内存中