Preview:
func isNumeric(s string) int {

	var r int

out:

	for {

		getInt, err := strconv.Atoi(s)

		if err != nil || getInt < 0 {

			fmt.Println("Not a (positive) integer number. Please insert a valid input:")

			fmt.Scan(&s)

		} else {

			if err == nil && getInt > 0 {

				r, _ = strconv.Atoi(s)

				break out

			}

		}

	}

	return r

}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter