Remove code, fix doc and fix test
This commit is contained in:
parent
7777789184
commit
733a2d3822
129
format.go
129
format.go
|
@ -6,10 +6,15 @@ import (
|
|||
"strconv"
|
||||
)
|
||||
|
||||
// NumField returns the number of rdata fields r has.
|
||||
func NumField(r RR) int {
|
||||
return reflect.ValueOf(r).Elem().NumField() - 1 // Remove RR_Header
|
||||
}
|
||||
|
||||
// Field returns the rdata field i as a string. Fields are indexed starting from 1.
|
||||
// Non existing fields will return the empty string. RR types that holds slice data,
|
||||
// for instance the NSEC type bitmap will return a single string where the types
|
||||
// are concatenated using a space.
|
||||
// RR types that holds slice data, for instance the NSEC type bitmap will return a single
|
||||
// string where the types are concatenated using a space.
|
||||
// Accessing non existing fields will cause a panic.
|
||||
func Field(r RR, i int) string {
|
||||
if i == 0 {
|
||||
return ""
|
||||
|
@ -89,121 +94,3 @@ func Field(r RR, i int) string {
|
|||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// NumField returns the number of rdata fields r has.
|
||||
func NumField(r RR) int {
|
||||
return reflect.ValueOf(r).Elem().NumField() - 1 // Remove RR_Header
|
||||
}
|
||||
|
||||
/*
|
||||
func format(r RR, f fmt.State, c rune) {
|
||||
switch c {
|
||||
case 'N':
|
||||
f.Write([]byte(r.Header().Name))
|
||||
case 'C':
|
||||
f.Write([]byte(Class(r.Header().Class).String()))
|
||||
case 'D':
|
||||
f.Write([]byte(strconv.Itoa(int(r.Header().Ttl))))
|
||||
case 'Y':
|
||||
f.Write([]byte(Type(r.Header().Rrtype).String()))
|
||||
case 's':
|
||||
f.Write([]byte(r.String()))
|
||||
default:
|
||||
println(string(c))
|
||||
f.Write([]byte("TODO"))
|
||||
}
|
||||
}
|
||||
|
||||
func format_Header(h *RR_Header, f fmt.State, c rune) {
|
||||
switch c {
|
||||
case 'N':
|
||||
f.Write([]byte(h.Name))
|
||||
case 'C':
|
||||
f.Write([]byte(Class(h.Class).String()))
|
||||
case 'D':
|
||||
f.Write([]byte(strconv.Itoa(int(h.Ttl))))
|
||||
case 'Y':
|
||||
f.Write([]byte(Type(h.Rrtype).String()))
|
||||
case 's':
|
||||
f.Write([]byte(h.String()))
|
||||
default:
|
||||
f.Write([]byte("TODO"))
|
||||
}
|
||||
}
|
||||
|
||||
func (h *RR_Header) Format(f fmt.State, c rune) { format_Header(h, f, c) }
|
||||
func (rr *RFC3597) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *PrivateRR) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *IPSECKEY) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *ANY) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
|
||||
// Quick 'n dirty:
|
||||
// for i in $(egrep '\sType.*:.*new\(' types.go | awk '{ print $6 } ' | sed 's/new(//' | sed 's/)//'); do
|
||||
// echo "func (rr *$i) Format(f fmt.State, c rune) { format(rr, f, c) }" ; done
|
||||
|
||||
func (rr *A) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *AAAA) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *AFSDB) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *CDS) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *CERT) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *CNAME) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *DHCID) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *DLV) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *DNAME) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *KEY) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *DNSKEY) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *DS) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *EUI48) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *EUI64) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *GID) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *GPOS) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *EID) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *HINFO) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *HIP) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *KX) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *L32) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *L64) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *LOC) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *LP) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *MB) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *MD) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *MF) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *MG) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *MINFO) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *MR) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *MX) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *NAPTR) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *NID) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *NINFO) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *NIMLOC) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *NS) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *NSAP) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *NSAPPTR) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *NSEC3) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *NSEC3PARAM) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *NSEC) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *OPENPGPKEY) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *OPT) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *PTR) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *RKEY) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *RP) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *PX) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *SIG) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *RRSIG) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *RT) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *SOA) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *SPF) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *SRV) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *SSHFP) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *TA) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *TALINK) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *TKEY) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *TLSA) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *TSIG) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *TXT) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *UID) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *UINFO) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *URI) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *WKS) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
func (rr *X25) Format(f fmt.State, c rune) { format(rr, f, c) }
|
||||
*/
|
||||
|
|
|
@ -1369,4 +1369,7 @@ func TestPrintfVerbsRdata(t *testing.T) {
|
|||
if Field(x, 1) != "first second" {
|
||||
t.Errorf("should be first second")
|
||||
}
|
||||
if Field(x, 0) != "" {
|
||||
t.Errorf("should be empty")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue