From a588d9aeccd5ba8206ab9867fb5ca847439dca5f Mon Sep 17 00:00:00 2001 From: Seraphim Strub Date: Wed, 17 Jul 2024 21:05:26 +0000 Subject: [PATCH] don't store nil slice to db --- cmd/domaincheckbot/dns/domain.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/domaincheckbot/dns/domain.go b/cmd/domaincheckbot/dns/domain.go index 9f18dc5..0419d44 100644 --- a/cmd/domaincheckbot/dns/domain.go +++ b/cmd/domaincheckbot/dns/domain.go @@ -60,6 +60,7 @@ func getNameserverForTLD(tld string) ([]string, error) { } func queryTLDNamserver(fqdn, tldServer string) ([]string, error) { + nameservers := []string{} // Create a new DNS message m := new(dns.Msg) // Set the question section of the message with the fqdn and query type @@ -71,16 +72,15 @@ func queryTLDNamserver(fqdn, tldServer string) ([]string, error) { // Send the DNS query to the TLD server r, _, err := c.Exchange(m, tldServer) if err != nil { - return nil, fmt.Errorf("dns query error: %v", err) + return nameservers, fmt.Errorf("dns query error: %v", err) } // Check for response errors if r.Rcode != dns.RcodeSuccess { - return nil, fmt.Errorf("failed to get a valid response for %v: %v", fqdn, r.Rcode) + return nameservers, fmt.Errorf("failed to get a valid response for %v: %v", fqdn, r.Rcode) } // Print the nameservers from the response - nameservers := []string{} for _, ans := range r.Ns { if ns, ok := ans.(*dns.NS); ok { nameservers = append(nameservers, strings.ToLower(ns.Ns))