Skip to content

Commit

Permalink
convert regex to MustCompile and backticks
Browse files Browse the repository at this point in the history
  • Loading branch information
wfaulk-bw committed Feb 8, 2019
1 parent d072fe4 commit 97bf5dc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ func absolute(name string) string {
return name
}

var reNaptr = regexp.MustCompile(`^([[:digit:]]+) ([[:digit:]]+) "([^"]*)" "([^"]*)" "([^"]*)" "?([^"]+)"?$`)

// ConvertRRSetToBind will convert a ResourceRecordSet to an array of RR entries
func ConvertRRSetToBind(rrset *route53.ResourceRecordSet) []dns.RR {
ret := []dns.RR{}
Expand Down Expand Up @@ -309,8 +311,7 @@ func ConvertRRSetToBind(rrset *route53.ResourceRecordSet) []dns.RR {
case "NAPTR":
for _, rr := range rrset.ResourceRecords {
// parse value
naptrRE, err := regexp.Compile("^([[:digit:]]+) ([[:digit:]]+) \"([^\"]*)\" \"([^\"]*)\" \"([^\"]*)\" \"?([^\"]+)\"?$")
naptr := naptrRE.FindStringSubmatch(*rr.Value)
naptr := reNaptr.FindStringSubmatch(*rr.Value)
fmt.Printf("naptr slice: %q\n", naptr)
order, _ := strconv.Atoi(naptr[1])
preference, _ := strconv.Atoi(naptr[2])
Expand Down

0 comments on commit 97bf5dc

Please sign in to comment.