6
84
Fork
You've already forked dns
39

feat(ZoneParserIter): Enable iter for zonefile parsing #635

Closed
TomOnTime wants to merge 1 commit from TomOnTime/dns:tlim_iter into main
pull from: TomOnTime/dns:tlim_iter
merge into: miekg:main
miekg:main
miekg:miek/26/mrt24di/tls
miekg:miek/26/mrt09ma/17
miekg:miek/26/feb15zo/13
miekg:miek/2025-10-26@1431
miekg:miek/2025-10-18@2017
Contributor
Copy link

Fixes #634

Add a wrapper around NewZoneParser()/Next() so that zonefiles may be parsed using Go iterators.

ZoneParserIter can be used as follows:

 for rr, err := range ZoneParserIter(strings.NewReader(mystring), "example.com", "zone.example.com") {
 if err != nil {
 return err
 }
 fmt.Printf("%s\n", rr.String())
 }
Fixes https://codeberg.org/miekg/dns/issues/634 Add a wrapper around NewZoneParser()/Next() so that zonefiles may be parsed using Go iterators. ZoneParserIter can be used as follows: ``` for rr, err := range ZoneParserIter(strings.NewReader(mystring), "example.com", "zone.example.com") { if err != nil { return err } fmt.Printf("%s\n", rr.String()) } ```
feat(ZoneParserIter): Enable iter for zonefile parsing
All checks were successful
/ test (pull_request) Successful in 1m57s
51fa236d74
Author
Contributor
Copy link

This is my first Go iterator. The name ZoneParserIter might not be best. Open to suggestions.

This is my first Go iterator. The name ZoneParserIter might not be best. Open to suggestions.
Owner
Copy link

Nice idea!

dns.Msg has one as well:

// RRs allows ranging over the RRs of all the sections in m. This includes the question, pseudo and stateful// sections.func(m*Msg)RRs()iter.Seq[RR]{

for parsing a zone, this iter should be method on *ZoneParser and probably also called RRs

Nice idea! `dns.Msg` has one as well: ```go // RRs allows ranging over the RRs of all the sections in m. This includes the question, pseudo and stateful // sections. func (m *Msg) RRs() iter.Seq[RR] { ``` for parsing a zone, this *iter* should be method on `*ZoneParser` and probably also called `RRs`
Owner
Copy link

welcome to codeberg :)

welcome to codeberg :)
Owner
Copy link

I have morphed this into #636, making these changes:

  • method in zp, called RRs()
  • simplfied the iter function a bit - think this still correct
  • example usage is now an Example test
  • kept your test
I have morphed this into #636, making these changes: - method in zp, called `RRs()` - simplfied the iter function a bit - think this still correct - example usage is now an Example test - kept your test
Owner
Copy link

also saw the error was never returned, so the iter's loop needs to be different, added test case to test for this .

also saw the error was never returned, so the iter's loop needs to be different, added test case to test for this .
Owner
Copy link

see (merged) #636

see (merged) #636
miekg closed this pull request 2026年01月24日 21:40:18 +01:00
All checks were successful
/ test (pull_request) Successful in 1m57s

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
miekg/dns!635
Reference in a new issue
miekg/dns
No description provided.
Delete branch "TomOnTime/dns:tlim_iter"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?