From 3c3fdeed13e110855238a048b0ece0a1f6fd9eb2 Mon Sep 17 00:00:00 2001 From: Mustafa Abdelrahman Date: Tue, 1 Aug 2023 16:07:40 +0200 Subject: [PATCH] Remove `github.com/pkg/errors` since it's not maintained anymore. Signed-off-by: Mustafa Abdelrahman --- cron.go | 15 ++++++++------- go.mod | 4 +--- go.sum | 2 -- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cron.go b/cron.go index 42eb42f..6c5823b 100644 --- a/cron.go +++ b/cron.go @@ -1,7 +1,8 @@ package cronmask import ( - "github.com/pkg/errors" + "errors" + "fmt" "strconv" "strings" "time" @@ -86,7 +87,7 @@ func validateRange(i, val int) error { return nil } - return errors.Errorf("expected %d to be in [%d,%d] range", val, validRange.start, validRange.end) + return fmt.Errorf("expected %d to be in [%d,%d] range", val, validRange.start, validRange.end) } func parseValue(fieldIdx int, raw string) (int, error) { @@ -110,28 +111,28 @@ func parseCronField(fieldIdx int, fieldStr string) (field, error) { fields := make([]field, 0, len(parts)) for _, p := range parts { if p == "" { - return nil, errors.Errorf("could not parse the cron field: %s. invalid list item: %s", fieldStr, p) + return nil, fmt.Errorf("could not parse the cron field: %s. invalid list item: %s", fieldStr, p) } possibleRangeFields := strings.Split(p, "-") if len(possibleRangeFields) == 1 { parsed, err := parseValue(fieldIdx, possibleRangeFields[0]) if err != nil { - return nil, errors.Wrapf(err, "could not parse cron field: %s. invalid list item: %s", fieldStr, p) + return nil, fmt.Errorf("could not parse cron field: %s. invalid list item: %s: %w", fieldStr, p, err) } fields = append(fields, constant{val: parsed}) } else if len(possibleRangeFields) == 2 { start, err := parseValue(fieldIdx, possibleRangeFields[0]) if err != nil { - return nil, errors.Wrapf(err, "could not parse cron field: %s. invalid list item: %s", fieldStr, p) + return nil, fmt.Errorf("could not parse cron field: %s. invalid list item: %s: %w", fieldStr, p, err) } end, err := parseValue(fieldIdx, possibleRangeFields[1]) if err != nil { - return nil, errors.Wrapf(err, "could not parse cron field: %s. invalid list item: %s", fieldStr, p) + return nil, fmt.Errorf("could not parse cron field: %s. invalid list item: %s: %w", fieldStr, p, err) } fields = append(fields, rangeF{start: start, end: end}) } else { - return nil, errors.Errorf("could not parse cron field: %s. invalid list item: %s", fieldStr, p) + return nil, fmt.Errorf("could not parse cron field: %s. invalid list item: %s", fieldStr, p) } } diff --git a/go.mod b/go.mod index 915ac9d..d4d3952 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,3 @@ module github.com/sarslanhan/cronmask -go 1.12 - -require github.com/pkg/errors v0.8.1 +go 1.19 diff --git a/go.sum b/go.sum index f29ab35..e69de29 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +0,0 @@ -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=