refactor: Add named returns #168

Merged
sam merged 3 commits from named-returns into master 2022-12-17 16:52:50 +00:00
6 changed files with 7 additions and 19 deletions
Showing only changes of commit d952d43705 - Show all commits

View file

@ -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 {

View file

@ -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 "<nil> MsgHdr", errNoMessage
}
var (
s string
opt *dns.OPT
)
var opt *dns.OPT
if !opts.Short {
if opts.Display.Comments {

View file

@ -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,

View file

@ -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{

View file

@ -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,

View file

@ -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,