(s string)
| 294 | } |
| 295 | |
| 296 | func timeoutDecode(s string) (time.Duration, error) { |
| 297 | size := len(s) |
| 298 | if size < 2 { |
| 299 | return 0, fmt.Errorf("timeout string is too short: %q", s) |
| 300 | } |
| 301 | d, ok := timeoutUnitToDuration(s[size-1]) |
| 302 | if !ok { |
| 303 | return 0, fmt.Errorf("timeout unit is not recognized: %q", s) |
| 304 | } |
| 305 | t, err := strconv.ParseInt(s[:size-1], 10, 64) |
| 306 | if err != nil { |
| 307 | return 0, err |
| 308 | } |
| 309 | return d * time.Duration(t), nil |
| 310 | } |
| 311 | |
| 312 | func timeoutUnitToDuration(u uint8) (d time.Duration, ok bool) { |
| 313 | switch u { |
no test coverage detected