From 58028d59ea8dc539d5e7eecb694d856532e690f3 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Mon, 23 Aug 2021 13:13:51 +0200 Subject: [PATCH] Improve argument parsing --- main.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 1a1c2cf..433ba61 100644 --- a/main.go +++ b/main.go @@ -79,13 +79,13 @@ func IsPrime(n int) bool { return true } -func parseArgs() (int, int, int, int) { - start := flag.Int("start", 0, "The start number") - max := flag.Int("max", 10_000, "The end value") - step := flag.Int("step-size", 1_000, "The job size") +func parseArgs() (start, max, step, printCount int) { + flag.IntVar(&start, "start", 0, "The start number") + flag.IntVar(&max, "max", 10_000, "The end value") + flag.IntVar(&step, "step-size", 1_000, "The job size") printCountDesc := `Number of primes to print. -1 to print all. Primes are not guaranteed to be sorted.` - printCount := flag.Int("print-count", 20, printCountDesc) + flag.IntVar(&printCount, "print-count", 20, printCountDesc) flag.Parse() - return *start, *max, *step, *printCount + return }