Skip to content

Commit

Permalink
Move all reversed map creation into reverse.go (#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmthrgd authored and miekg committed Jan 4, 2019
1 parent 5b818ee commit e8b24e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 0 additions & 6 deletions dnssec.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ var AlgorithmToString = map[uint8]string{
PRIVATEOID: "PRIVATEOID",
}

// StringToAlgorithm is the reverse of AlgorithmToString.
var StringToAlgorithm = reverseInt8(AlgorithmToString)

// AlgorithmToHash is a map of algorithm crypto hash IDs to crypto.Hash's.
var AlgorithmToHash = map[uint8]crypto.Hash{
RSAMD5: crypto.MD5, // Deprecated in RFC 6725
Expand Down Expand Up @@ -102,9 +99,6 @@ var HashToString = map[uint8]string{
SHA512: "SHA512",
}

// StringToHash is a map of names to hash IDs.
var StringToHash = reverseInt8(HashToString)

// DNSKEY flag values.
const (
SEP = 1
Expand Down
9 changes: 9 additions & 0 deletions reverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ func init() {
StringToRcode["NOTIMPL"] = RcodeNotImplemented
}

// StringToAlgorithm is the reverse of AlgorithmToString.
var StringToAlgorithm = reverseInt8(AlgorithmToString)

// StringToHash is a map of names to hash IDs.
var StringToHash = reverseInt8(HashToString)

// StringToCertType is the reverseof CertTypeToString.
var StringToCertType = reverseInt16(CertTypeToString)

// Reverse a map
func reverseInt8(m map[uint8]string) map[string]uint8 {
n := make(map[string]uint8, len(m))
Expand Down
3 changes: 0 additions & 3 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,6 @@ var CertTypeToString = map[uint16]string{
CertOID: "OID",
}

// StringToCertType is the reverseof CertTypeToString.
var StringToCertType = reverseInt16(CertTypeToString)

//go:generate go run types_generate.go

// Question holds a DNS question. There can be multiple questions in the
Expand Down

0 comments on commit e8b24e8

Please sign in to comment.