From c4bad5c1bca04fb542e65760e9387b119e7b3614 Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Tue, 8 Aug 2023 19:55:44 +0800 Subject: [PATCH] lib/rest: remove unnecessary nil check From the Go docs: "A `nil` map is equivalent to an empty map. [1] Therefore, an additional nil check for `opts.ExtraHeaders` before the loop is unnecessary because `opts.ExtraHeaders` is a `map`. [1]: https://go.dev/ref/spec#Map_types Signed-off-by: Eng Zer Jun --- lib/rest/rest.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/rest/rest.go b/lib/rest/rest.go index c4fb51b6a..a7bba472b 100644 --- a/lib/rest/rest.go +++ b/lib/rest/rest.go @@ -275,10 +275,8 @@ func (api *Client) Call(ctx context.Context, opts *Opts) (resp *http.Response, e req.Close = true } // Set any extra headers - if opts.ExtraHeaders != nil { - for k, v := range opts.ExtraHeaders { - headers[k] = v - } + for k, v := range opts.ExtraHeaders { + headers[k] = v } // add any options to the headers fs.OpenOptionAddHeaders(opts.Options, headers)