Make "go vet" happy
This commit is contained in:
1 parent
56859a9c30
commit
41ae6e0b7a
1 file changed
+13
-9
+13
-9
@@ -31,7 +31,7 @@ type ZoneObserver interface {
|
|||||||
ObserveInaddr(inaddr string, observer ZoneRecordObserver) error
|
ObserveInaddr(inaddr string, observer ZoneRecordObserver) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type ZoneRecordObserver func(ZoneRecord)
|
type ZoneRecordObserver func()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -51,16 +51,16 @@ func (r Record) Weight() int { return r.weight }
|
|||||||
func (i Record) String() string {
|
func (i Record) String() string {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
if len(i.Name()) > 0 {
|
if len(i.Name()) > 0 {
|
||||||
buf.WriteString(fmt.Sprintf("%s", i.Name()))
|
fmt.Fprintf(&buf, "%s", i.Name())
|
||||||
}
|
}
|
||||||
if !i.IP().IsUnspecified() {
|
if !i.IP().IsUnspecified() {
|
||||||
buf.WriteString(fmt.Sprintf("[%s]", i.IP()))
|
fmt.Fprintf(&buf, "[%s]", i.IP())
|
||||||
}
|
}
|
||||||
if i.Priority() > 0 {
|
if i.Priority() > 0 {
|
||||||
buf.WriteString(fmt.Sprintf("/P:%d", i.Priority()))
|
fmt.Fprintf(&buf, "/P:%d", i.Priority())
|
||||||
}
|
}
|
||||||
if i.Weight() > 0 {
|
if i.Weight() > 0 {
|
||||||
buf.WriteString(fmt.Sprintf("/W:%d", i.Weight()))
|
fmt.Fprintf(&buf, "/W:%d", i.Weight())
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf.String()
|
return buf.String()
|
||||||
@@ -68,6 +68,10 @@ func (i Record) String() string {
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
func newParseError(reason string, addr string) *net.ParseError {
|
||||||
|
return &net.ParseError{Type: reason, Text: addr}
|
||||||
|
}
|
||||||
|
|
||||||
// simple IPv4 type that can be used as a key in a map (in contrast with net.IP), used for sets of IPs, etc...
|
// simple IPv4 type that can be used as a key in a map (in contrast with net.IP), used for sets of IPs, etc...
|
||||||
type IPv4 [4]byte
|
type IPv4 [4]byte
|
||||||
|
|
||||||
@@ -79,7 +83,7 @@ func ipToIPv4(nip net.IP) IPv4 { ip := nip.To4(); return IPv4([4]byte{ip[0], ip
|
|||||||
func addrToIPv4(addr string) (IPv4, error) {
|
func addrToIPv4(addr string) (IPv4, error) {
|
||||||
ip := net.ParseIP(addr)
|
ip := net.ParseIP(addr)
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
return IPv4{}, &net.ParseError{"IP address", addr}
|
return IPv4{}, newParseError("IP address", addr)
|
||||||
}
|
}
|
||||||
return ipToIPv4(ip), nil
|
return ipToIPv4(ip), nil
|
||||||
}
|
}
|
||||||
@@ -88,18 +92,18 @@ func addrToIPv4(addr string) (IPv4, error) {
|
|||||||
func raddrToIPv4(addr string) (IPv4, error) {
|
func raddrToIPv4(addr string) (IPv4, error) {
|
||||||
l := len(addr)
|
l := len(addr)
|
||||||
if l < rdnsDomainLen+1 {
|
if l < rdnsDomainLen+1 {
|
||||||
return IPv4{}, &net.ParseError{"too short reverse IP address", addr}
|
return IPv4{}, newParseError("too short reverse IP address", addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
suffixLen := l - rdnsDomainLen
|
suffixLen := l - rdnsDomainLen
|
||||||
suffix := addr[suffixLen+1:]
|
suffix := addr[suffixLen+1:]
|
||||||
if suffix != RDNSDomain {
|
if suffix != RDNSDomain {
|
||||||
return IPv4{}, &net.ParseError{"suffix of reverse IP address", addr}
|
return IPv4{}, newParseError("suffix of reverse IP address", addr)
|
||||||
}
|
}
|
||||||
ipStr := addr[:suffixLen]
|
ipStr := addr[:suffixLen]
|
||||||
revIP := net.ParseIP(ipStr)
|
revIP := net.ParseIP(ipStr)
|
||||||
if revIP == nil {
|
if revIP == nil {
|
||||||
return IPv4{}, &net.ParseError{"reverse IP address", addr}
|
return IPv4{}, newParseError("reverse IP address", addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
revIP4 := revIP.To4()
|
revIP4 := revIP.To4()
|
||||||
|
|||||||
Reference in new issue
Block a user