func ParseWaitConfig(s string) (*WaitConfig, error) {
	s = strings.TrimSpace(s)
	if len(s) < 1 {
		return nil, ErrWaitStringEmpty
	}

	parts := strings.Split(s, ":")

	var min, max time.Duration
	var err error

	switch len(parts) {
	case 1:
		min, err = time.ParseDuration(strings.TrimSpace(parts[0]))
		if err != nil {
			return nil, err
		}

		max = 4 * min
	case 2:
		min, err = time.ParseDuration(strings.TrimSpace(parts[0]))
		if err != nil {
			return nil, err
		}

		max, err = time.ParseDuration(strings.TrimSpace(parts[1]))
		if err != nil {
			return nil, err
		}
	default:
		return nil, ErrWaitInvalidFormat
	}

	if min < 0 || max < 0 {
		return nil, ErrWaitNegative
	}

	if max < min {
		return nil, ErrWaitMinLTMax
	}

	var c WaitConfig
	c.Min = TimeDuration(min)
	c.Max = TimeDuration(max)

	return &c, nil
}
func ParseWaitConfig(s string) (*WaitConfig, error) {
	s = strings.TrimSpace(s)
	if len(s) < 1 {
		return nil, ErrWaitStringEmpty
	}

	parts := strings.Split(s, ":")

	var min, max time.Duration
	var err error

	switch len(parts) {
	case 1:
		min, err = time.ParseDuration(strings.TrimSpace(parts[0]))
		if err != nil {
			return nil, err
		}

		max = 4 * min
	case 2:
		min, err = time.ParseDuration(strings.TrimSpace(parts[0]))
		if err != nil {
			return nil, err
		}

		max, err = time.ParseDuration(strings.TrimSpace(parts[1]))
		if err != nil {
			return nil, err
		}
	default:
		return nil, ErrWaitInvalidFormat
	}

	if min < 0 || max < 0 {
		return nil, ErrWaitNegative
	}

	if max < min {
		return nil, ErrWaitMinLTMax
	}

	var c WaitConfig
	c.Min = TimeDuration(min)
	c.Max = TimeDuration(max)

	return &c, nil
}
func ParseWaitConfig ( s string ) ( * WaitConfig , error ) { s = strings . TrimSpace ( s ) if len ( s ) < 1 { return nil , ErrWaitStringEmpty } parts := strings . Split ( s , " " ) var min , max time . Duration var err error switch len ( parts ) { case 1 : min , err = time . ParseDuration ( strings . TrimSpace ( parts [ 0 ] ) ) if err != nil { return nil , err } max = 4 * min case 2 : min , err = time . ParseDuration ( strings . TrimSpace ( parts [ 0 ] ) ) if err != nil { return nil , err } max , err = time . ParseDuration ( strings . TrimSpace ( parts [ 1 ] ) ) if err != nil { return nil , err } default : return nil , ErrWaitInvalidFormat } if min < 0 || max < 0 { return nil , ErrWaitNegative } if max < min { return nil , ErrWaitMinLTMax } var c WaitConfig c . Min = TimeDuration ( min ) c . Max = TimeDuration ( max ) return & c , nil }
// ParseWaitConfig parses a string of the format `minimum(:maximum)` into a
// WaitConfig.
ParseWaitConfig parses a string of the format minimum ( : maximum ) into a WaitConfig .