From 1b1637b5e66a482168c6e3f8ef5ab0f3e2ba45e4 Mon Sep 17 00:00:00 2001 From: Daniel Gurney Date: Thu, 27 Sep 2018 17:46:32 +0300 Subject: [PATCH] Use default values if width and/or height is 0 --- png.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/png.go b/png.go index 57b323e..14162af 100644 --- a/png.go +++ b/png.go @@ -14,7 +14,7 @@ import ( "time" ) -const version = "1.0.0" +const version = "1.0.1" var t = time.Now().UnixNano() var rndseed = rand.NewSource(t) @@ -55,6 +55,15 @@ func main() { amount := flag.Int("a", 1, "Amount of images to generate.") ver := flag.Bool("v", false, "Show version number and exit.") flag.Parse() + switch { + case *height == 0 && *width == 0: + *width = 500 + *height = 500 + case *width == 0: + *width = 500 + case *height == 0: + *height = 500 + } if *ver { fmt.Printf("Random PNG generator v%s by Daniel Gurney\n", version) return