1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Switch to Go 1.13 error wrapping (#604)

* Replaced errors.Wrap with fmt.Errorf (#589)

* Find:    errors\.Wrap\(([^,]+),\s+(["`][^"`]*)(["`])\)
  Replace: fmt.Errorf($2: %w$3, $1)

* Replaced errors.Wrapf with fmt.Errorf (#589)

* Find:    errors\.Wrapf\(([^,]+),\s+(["`][^"`]*)(["`])\)
  Replace: fmt.Errorf($2: %w$3, $1)
* Find:    errors\.Wrapf\(([^,]+),\s+(["`][^"`]*)(["`])(,[^)]+)\)
* Replace: fmt.Errorf($2: %w$3$4, $1)

* Replaced errors.Errorf with fmt.Errorf (#589)

* Find:    errors\.Errorf
  Replace: fmt.Errorf

* Cleaned up remaining imports

* Cleanup

* Regenerate provider support matrix

This was broken by #533 ... and it's now the third time this has been missed.
This commit is contained in:
Patrick Gaskin
2020-01-28 11:06:56 -05:00
committed by Tom Limoncelli
parent cae35a2c8f
commit 825ba2d081
64 changed files with 328 additions and 379 deletions

View File

@ -1,14 +1,10 @@
package spflib
import (
"fmt"
"strings"
"bytes"
"fmt"
"io"
"github.com/pkg/errors"
"strings"
)
// SPFRecord stores the parts of an SPF record.
@ -48,7 +44,7 @@ var qualifiers = map[byte]bool{
// Parse parses a raw SPF record.
func Parse(text string, dnsres Resolver) (*SPFRecord, error) {
if !strings.HasPrefix(text, "v=spf1 ") {
return nil, errors.Errorf("Not an spf record")
return nil, fmt.Errorf("Not an spf record")
}
parts := strings.Split(text, " ")
rec := &SPFRecord{}
@ -79,7 +75,7 @@ func Parse(text string, dnsres Resolver) (*SPFRecord, error) {
// pi + 2: because pi starts at 0 when it iterates starting on parts[1],
// and because len(parts) is one bigger than the highest index.
if (pi + 2) != len(parts) {
return nil, errors.Errorf("%s must be last item", part)
return nil, fmt.Errorf("%s must be last item", part)
}
p.IncludeDomain = strings.TrimPrefix(part, "redirect=")
} else {
@ -93,13 +89,13 @@ func Parse(text string, dnsres Resolver) (*SPFRecord, error) {
}
p.IncludeRecord, err = Parse(subRecord, dnsres)
if err != nil {
return nil, errors.Errorf("In included spf: %s", err)
return nil, fmt.Errorf("In included spf: %s", err)
}
}
} else if strings.HasPrefix(part, "exists:") || strings.HasPrefix(part, "ptr:") {
p.IsLookup = true
} else {
return nil, errors.Errorf("Unsupported spf part %s", part)
return nil, fmt.Errorf("Unsupported spf part %s", part)
}
}