INNER CODE UNIT · Go

func

offen/docker-volume-backup · cmd/backup/config.go:204

func (n *NaturalNumber) Decode(v string) error {
	asInt, err := strconv.Atoi(v)
	if err != nil {
		return errwrap.Wrap(nil, fmt.Sprintf("error converting %s to int", v))
	}
	if asInt <= 0 {
		return errwrap.Wrap(nil, fmt.Sprintf("expected a natural number, got %d", asInt))
	}
	*n = NaturalNumber(asInt)
	return nil
}

func (n *NaturalNumber) Int() int {
	return int(*n)
}

// WholeNumber is a type that can be used to decode a positive whole number, including zero
type WholeNumber int

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…