From 2326160f2f05e5cc4d0e26bdd6a75a42c29f92c8 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 26 Apr 2023 21:32:08 +0700 Subject: [PATCH] Do not rely on unspecified assignment order of return statement See: https://github.com/golang/go/issues/58233 --- doh.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doh.go b/doh.go index e2e6586..931b6a1 100644 --- a/doh.go +++ b/doh.go @@ -85,7 +85,10 @@ func (r *dohResolver) Resolve(ctx context.Context, msg *dns.Msg) (*dns.Msg, erro } answer := new(dns.Msg) - return answer, answer.Unpack(buf) + if err := answer.Unpack(buf); err != nil { + return nil, fmt.Errorf("answer.Unpack: %w", err) + } + return answer, nil } func addHeader(ctx context.Context, req *http.Request, sendClientInfo bool) {