From e871aa3046a981eccf9b2a042b7d2ced9f109355 Mon Sep 17 00:00:00 2001 From: Ethel Morgan Date: Tue, 7 Jul 2020 15:35:24 +0100 Subject: add ErrRequired canonical error for "flag is required" --- parsefuncs.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/parsefuncs.go b/parsefuncs.go index 0263a5a..793e732 100644 --- a/parsefuncs.go +++ b/parsefuncs.go @@ -11,9 +11,14 @@ import ( "strings" ) +var ( + // ErrRequired provides a canonical "you must set this flag" error message. + ErrRequired = errors.New("must not be empty") +) + func RequiredString(raw string) (interface{}, error) { if raw == "" { - return nil, errors.New("must not be empty") + return nil, ErrRequired } return raw, nil } -- cgit v1.2.3