diff --git a/defaults.go b/defaults.go index d874e300..d47b0b1f 100644 --- a/defaults.go +++ b/defaults.go @@ -349,10 +349,7 @@ func ReverseAddr(addr string) (arpa string, err error) { // Add it, in reverse, to the buffer for i := len(ip) - 1; i >= 0; i-- { v := ip[i] - buf = append(buf, hexDigit[v&0xF]) - buf = append(buf, '.') - buf = append(buf, hexDigit[v>>4]) - buf = append(buf, '.') + buf = append(buf, hexDigit[v&0xF], '.', hexDigit[v>>4], '.') } // Append "ip6.arpa." and return (buf already has the final .) buf = append(buf, "ip6.arpa."...) diff --git a/dnssec_test.go b/dnssec_test.go index a43afeba..ca196033 100644 --- a/dnssec_test.go +++ b/dnssec_test.go @@ -325,7 +325,7 @@ Activate: 20110302104537` } switch priv := p.(type) { case *rsa.PrivateKey: - if 65537 != priv.PublicKey.E { + if priv.PublicKey.E != 65537 { t.Error("exponenent should be 65537") } default: diff --git a/dnsutil/util.go b/dnsutil/util.go index 76ac4de6..f7a1547c 100644 --- a/dnsutil/util.go +++ b/dnsutil/util.go @@ -30,10 +30,10 @@ func AddOrigin(s, origin string) string { if dns.IsFqdn(s) { return s // s is already a FQDN, no need to mess with it. } - if len(origin) == 0 { + if origin == "" { return s // Nothing to append. } - if s == "@" || len(s) == 0 { + if s == "@" || s == "" { return origin // Expand apex. } if origin == "." { @@ -50,7 +50,7 @@ func TrimDomainName(s, origin string) string { // If the return value ends in a ".", the domain was not the suffix. // origin can end in "." or not. Either way the results should be the same. - if len(s) == 0 { + if s == "" { return "@" } // Someone is using TrimDomainName(s, ".") to remove a dot if it exists. diff --git a/labels.go b/labels.go index df1675df..f9faacfe 100644 --- a/labels.go +++ b/labels.go @@ -10,7 +10,7 @@ package dns // escaped dots (\.) for instance. // s must be a syntactically valid domain name, see IsDomainName. func SplitDomainName(s string) (labels []string) { - if len(s) == 0 { + if s == "" { return nil } fqdnEnd := 0 // offset of the final '.' or the length of the name diff --git a/parse_test.go b/parse_test.go index 1895506e..2cbed373 100644 --- a/parse_test.go +++ b/parse_test.go @@ -245,8 +245,7 @@ func testTXTRRQuick(t *testing.T) { rrbytes := make([]byte, 0, len(owner)+2+2+4+2+len(rdata)) rrbytes = append(rrbytes, owner...) rrbytes = append(rrbytes, typeAndClass...) - rrbytes = append(rrbytes, byte(len(rdata)>>8)) - rrbytes = append(rrbytes, byte(len(rdata))) + rrbytes = append(rrbytes, byte(len(rdata)>>8), byte(len(rdata))) rrbytes = append(rrbytes, rdata...) rr, _, err := UnpackRR(rrbytes, 0) if err != nil { diff --git a/scan.go b/scan.go index 67161de2..0b44f756 100644 --- a/scan.go +++ b/scan.go @@ -1233,7 +1233,7 @@ func stringToCm(token string) (e, m uint8, ok bool) { // 'nn.1' must be treated as 'nn-meters and 10cm, not 1cm. cmeters *= 10 } - if len(s[0]) == 0 { + if s[0] == "" { // This will allow omitting the 'meter' part, like .01 (meaning 0.01m = 1cm). break } diff --git a/scan_rr.go b/scan_rr.go index 23b4043b..1f2392a5 100644 --- a/scan_rr.go +++ b/scan_rr.go @@ -662,7 +662,7 @@ East: Altitude: c.Next() // zBlank l, _ = c.Next() - if len(l.token) == 0 || l.err { + if l.token == "" || l.err { return &ParseError{"", "bad LOC Altitude", l} } if l.token[len(l.token)-1] == 'M' || l.token[len(l.token)-1] == 'm' { @@ -722,7 +722,7 @@ func (rr *HIP) parse(c *zlexer, o string) *ParseError { c.Next() // zBlank l, _ = c.Next() // zString - if len(l.token) == 0 || l.err { + if l.token == "" || l.err { return &ParseError{"", "bad HIP Hit", l} } rr.Hit = l.token // This can not contain spaces, see RFC 5205 Section 6. @@ -730,7 +730,7 @@ func (rr *HIP) parse(c *zlexer, o string) *ParseError { c.Next() // zBlank l, _ = c.Next() // zString - if len(l.token) == 0 || l.err { + if l.token == "" || l.err { return &ParseError{"", "bad HIP PublicKey", l} } rr.PublicKey = l.token // This cannot contain spaces @@ -997,7 +997,7 @@ func (rr *NSEC3) parse(c *zlexer, o string) *ParseError { rr.Iterations = uint16(i) c.Next() l, _ = c.Next() - if len(l.token) == 0 || l.err { + if l.token == "" || l.err { return &ParseError{"", "bad NSEC3 Salt", l} } if l.token != "-" { @@ -1007,7 +1007,7 @@ func (rr *NSEC3) parse(c *zlexer, o string) *ParseError { c.Next() l, _ = c.Next() - if len(l.token) == 0 || l.err { + if l.token == "" || l.err { return &ParseError{"", "bad NSEC3 NextDomain", l} } rr.HashLength = 20 // Fix for NSEC3 (sha1 160 bits) diff --git a/sig0.go b/sig0.go index 9ef13ccf..e781c9bb 100644 --- a/sig0.go +++ b/sig0.go @@ -17,7 +17,7 @@ func (rr *SIG) Sign(k crypto.Signer, m *Msg) ([]byte, error) { if k == nil { return nil, ErrPrivKey } - if rr.KeyTag == 0 || len(rr.SignerName) == 0 || rr.Algorithm == 0 { + if rr.KeyTag == 0 || rr.SignerName == "" || rr.Algorithm == 0 { return nil, ErrKey } @@ -78,7 +78,7 @@ func (rr *SIG) Verify(k *KEY, buf []byte) error { if k == nil { return ErrKey } - if rr.KeyTag == 0 || len(rr.SignerName) == 0 || rr.Algorithm == 0 { + if rr.KeyTag == 0 || rr.SignerName == "" || rr.Algorithm == 0 { return ErrKey } diff --git a/svcb.go b/svcb.go index 1373fe21..ec0a76f4 100644 --- a/svcb.go +++ b/svcb.go @@ -321,7 +321,7 @@ func (s *SVCBAlpn) pack() ([]byte, error) { // Liberally estimate the size of an alpn as 10 octets b := make([]byte, 0, 10*len(s.Alpn)) for _, e := range s.Alpn { - if len(e) == 0 { + if e == "" { return nil, errors.New("dns: svcbalpn: empty alpn-id") } if len(e) > 255 { @@ -390,7 +390,7 @@ func (*SVCBNoDefaultAlpn) unpack(b []byte) error { } func (*SVCBNoDefaultAlpn) parse(b string) error { - if len(b) != 0 { + if b != "" { return errors.New("dns: svcbnodefaultalpn: no_default_alpn must have no value") } return nil diff --git a/types.go b/types.go index 9e379eb3..2ed2720a 100644 --- a/types.go +++ b/types.go @@ -1472,7 +1472,7 @@ func StringToTime(s string) (uint32, error) { // saltToString converts a NSECX salt to uppercase and returns "-" when it is empty. func saltToString(s string) string { - if len(s) == 0 { + if s == "" { return "-" } return strings.ToUpper(s)