From d952d4370592d027875354542c89f81720134ec0 Mon Sep 17 00:00:00 2001 From: Sam Therapy Date: Mon, 12 Dec 2022 19:54:23 +0100 Subject: [PATCH] refactor: Add named returns somewhere Signed-off-by: Sam Therapy --- cmd/cli.go | 2 +- pkg/query/print.go | 7 ++----- pkg/resolvers/DNSCrypt.go | 2 +- pkg/resolvers/HTTPS.go | 4 +--- pkg/resolvers/QUIC.go | 4 +--- pkg/resolvers/general.go | 7 +------ 6 files changed, 7 insertions(+), 19 deletions(-) diff --git a/cmd/cli.go b/cmd/cli.go index 3c06037..4dcf875 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -17,7 +17,7 @@ import ( // ParseCLI parses arguments given from the CLI and passes them into an `Options` // struct. -func ParseCLI(args []string, version string) (*util.Options, error) { +func ParseCLI(args []string, version string) (opts *util.Options, err error) { // Parse the standard flags opts, misc, err := parseFlags(args, version) if err != nil { diff --git a/pkg/query/print.go b/pkg/query/print.go index 33734d6..8171ed9 100644 --- a/pkg/query/print.go +++ b/pkg/query/print.go @@ -21,15 +21,12 @@ import ( // ToString turns the response into something that looks a lot like dig // // Much of this is taken from https://github.com/miekg/dns/blob/master/msg.go#L900 -func ToString(res util.Response, opts *util.Options) (string, error) { +func ToString(res util.Response, opts *util.Options) (s string, err error) { if res.DNS == nil { return " MsgHdr", errNoMessage } - var ( - s string - opt *dns.OPT - ) + var opt *dns.OPT if !opts.Short { if opts.Display.Comments { diff --git a/pkg/resolvers/DNSCrypt.go b/pkg/resolvers/DNSCrypt.go index 9bff6bd..a80df61 100644 --- a/pkg/resolvers/DNSCrypt.go +++ b/pkg/resolvers/DNSCrypt.go @@ -19,7 +19,7 @@ type DNSCryptResolver struct { var _ Resolver = (*DNSCryptResolver)(nil) // LookUp performs a DNS query. -func (resolver *DNSCryptResolver) LookUp(msg *dns.Msg) (util.Response, error) { +func (resolver *DNSCryptResolver) LookUp(msg *dns.Msg) (resp util.Response, err error) { client := dnscrypt.Client{ Timeout: resolver.opts.Request.Timeout, UDPSize: 1232, diff --git a/pkg/resolvers/HTTPS.go b/pkg/resolvers/HTTPS.go index bfe1660..9182095 100644 --- a/pkg/resolvers/HTTPS.go +++ b/pkg/resolvers/HTTPS.go @@ -23,9 +23,7 @@ type HTTPSResolver struct { var _ Resolver = (*HTTPSResolver)(nil) // LookUp performs a DNS query. -func (resolver *HTTPSResolver) LookUp(msg *dns.Msg) (util.Response, error) { - var resp util.Response - +func (resolver *HTTPSResolver) LookUp(msg *dns.Msg) (resp util.Response, err error) { resolver.client = http.Client{ Timeout: resolver.opts.Request.Timeout, Transport: &http.Transport{ diff --git a/pkg/resolvers/QUIC.go b/pkg/resolvers/QUIC.go index 53b96b7..c24c0e8 100644 --- a/pkg/resolvers/QUIC.go +++ b/pkg/resolvers/QUIC.go @@ -22,9 +22,7 @@ type QUICResolver struct { var _ Resolver = (*QUICResolver)(nil) // LookUp performs a DNS query. -func (resolver *QUICResolver) LookUp(msg *dns.Msg) (util.Response, error) { - var resp util.Response - +func (resolver *QUICResolver) LookUp(msg *dns.Msg) (resp util.Response, err error) { tls := &tls.Config{ //nolint:gosec // This is intentional if the user requests it InsecureSkipVerify: resolver.opts.TLSNoVerify, diff --git a/pkg/resolvers/general.go b/pkg/resolvers/general.go index e4a9435..39b7a03 100644 --- a/pkg/resolvers/general.go +++ b/pkg/resolvers/general.go @@ -19,12 +19,7 @@ type StandardResolver struct { var _ Resolver = (*StandardResolver)(nil) // LookUp performs a DNS query. -func (resolver *StandardResolver) LookUp(msg *dns.Msg) (util.Response, error) { - var ( - resp util.Response - err error - ) - +func (resolver *StandardResolver) LookUp(msg *dns.Msg) (resp util.Response, err error) { dnsClient := new(dns.Client) dnsClient.Dialer = &net.Dialer{ Timeout: resolver.opts.Request.Timeout,