From eced7be07c6ef6d5d983feb11b595c1603ffc9fb Mon Sep 17 00:00:00 2001 From: Steve Milner Date: Fri, 13 Oct 2017 15:50:00 -0400 Subject: [PATCH] dockertar-sha256-helper: Error without arg Provide a human understandable error when an argument is not provided. Signed-off-by: Steve Milner Closes: #1117 Approved by: giuseppe --- dockertar-sha256-helper.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dockertar-sha256-helper.go b/dockertar-sha256-helper.go index 4a4498ff..3e0793e9 100644 --- a/dockertar-sha256-helper.go +++ b/dockertar-sha256-helper.go @@ -1,14 +1,18 @@ package main import ( - "fmt" "compress/gzip" - "os" - "io" "crypto/sha256" + "fmt" + "io" + "os" ) func main() { + // Require one positional argument + if len(os.Args) != 2 { + panic("One positional argument is required") + } reader, err := os.Open(os.Args[1]) if err != nil { os.Exit(1)