Skip to content

Commit

Permalink
Merge pull request miekg#321 from miekg/issue-306-improve-docs
Browse files Browse the repository at this point in the history
Improve docs on the label functions
  • Loading branch information
miekg committed Feb 28, 2016
2 parents c793f40 + 84e9295 commit d947227
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package dns
// The root label (.) returns nil. Note that using
// strings.Split(s) will work in most cases, but does not handle
// escaped dots (\.) for instance.
// s must be a syntactically valid domain name, see IsDomainName.
func SplitDomainName(s string) (labels []string) {
if len(s) == 0 {
return nil
Expand Down Expand Up @@ -46,6 +47,8 @@ func SplitDomainName(s string) (labels []string) {
//
// www.miek.nl. and miek.nl. have two labels in common: miek and nl
// www.miek.nl. and www.bla.nl. have one label in common: nl
//
// s1 and s2 must be syntactically valid domain names.
func CompareDomainName(s1, s2 string) (n int) {
s1 = Fqdn(s1)
s2 = Fqdn(s2)
Expand Down Expand Up @@ -86,6 +89,7 @@ func CompareDomainName(s1, s2 string) (n int) {
}

// CountLabel counts the the number of labels in the string s.
// s must be a syntactically valid domain name.
func CountLabel(s string) (labels int) {
if s == "." {
return
Expand All @@ -103,8 +107,8 @@ func CountLabel(s string) (labels int) {

// Split splits a name s into its label indexes.
// www.miek.nl. returns []int{0, 4, 9}, www.miek.nl also returns []int{0, 4, 9}.
// .www.miek.nl. returns []int{0, 1, 5, 10}
// The root name (.) returns nil. Also see SplitDomainName.
// The root name (.) returns nil. Also see SplitDomainName.
// s must be a syntactically valid domain name.
func Split(s string) []int {
if s == "." {
return nil
Expand Down

0 comments on commit d947227

Please sign in to comment.