Skip to content

Commit

Permalink
Improve NewRR documentation (#1531)
Browse files Browse the repository at this point in the history
In particular, document the default origin.
  • Loading branch information
gibson042 authored Jan 21, 2024
1 parent a493770 commit 21ba49c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ type ttlState struct {
isByDirective bool // isByDirective indicates whether ttl was set by a $TTL directive
}

// NewRR reads the RR contained in the string s. Only the first RR is returned.
// NewRR reads a string s and returns the first RR.
// If s contains no records, NewRR will return nil with no error.
//
// The class defaults to IN and TTL defaults to 3600. The full zone file syntax
// like $TTL, $ORIGIN, etc. is supported. All fields of the returned RR are
// set, except RR.Header().Rdlength which is set to 0.
// The class defaults to IN, TTL defaults to 3600, and
// origin for resolving relative domain names defaults to the DNS root (.).
// Full zone file syntax is supported, including directives like $TTL and $ORIGIN.
// All fields of the returned RR are set from the read data, except RR.Header().Rdlength which is set to 0.
func NewRR(s string) (RR, error) {
if len(s) > 0 && s[len(s)-1] != '\n' { // We need a closing newline
return ReadRR(strings.NewReader(s+"\n"), "")
Expand Down

0 comments on commit 21ba49c

Please sign in to comment.