Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove github.com/pkg/errors since it's not maintained anymore. #3

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions cron.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package cronmask

import (
"github.com/pkg/errors"
"errors"
"fmt"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
}
}

Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module github.com/sarslanhan/cronmask

go 1.12

require github.com/pkg/errors v0.8.1
go 1.19
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=