Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package endpoints | |
| 6 | |
| 7 import ( | |
| 8 "time" | |
| 9 | |
| 10 "github.com/luci/luci-go/common/proto/google" | |
| 11 ) | |
| 12 | |
| 13 // MinDuration selects the smallest duration that is > 0 from a set of | |
| 14 // google.Duration protobufs. | |
| 15 // | |
| 16 // If none of the supplied Durations are > 0, 0 will be returned. | |
| 17 func MinDuration(candidates ...*google.Duration) (exp time.Duration) { | |
|
nodir
2016/05/19 17:17:21
I like that you called it Min. It is more concrete
dnj (Google)
2016/05/19 20:10:46
Agreed.
| |
| 18 for _, c := range candidates { | |
| 19 if cd := c.Duration(); cd > 0 && (exp <= 0 || cd < exp) { | |
| 20 exp = cd | |
| 21 } | |
| 22 } | |
| 23 return | |
| 24 } | |
| OLD | NEW |