♻️ Refactor: Remove redundant nil check (#2584)

From the Go docs:

  "If the map is nil, the number of iterations is 0." [1]

Therefore, an additional nil check for before the loop is unnecessary.

[1]: https://go.dev/ref/spec#For_range

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
pull/2585/head
Eng Zer Jun 2023-08-18 02:49:53 +08:00 committed by GitHub
parent 85d1f6895a
commit 242ff94505
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -141,10 +141,8 @@ func New(config ...Config) fiber.Handler {
if len(e.cencoding) > 0 {
c.Response().Header.SetBytesV(fiber.HeaderContentEncoding, e.cencoding)
}
if e.headers != nil {
for k, v := range e.headers {
c.Response().Header.SetBytesV(k, v)
}
for k, v := range e.headers {
c.Response().Header.SetBytesV(k, v)
}
// Set Cache-Control header if enabled
if cfg.CacheControl {

View File

@ -199,10 +199,8 @@ func createTagMap(cfg *Config) map[string]LogFunc {
},
}
// merge with custom tags from user
if cfg.CustomTags != nil {
for k, v := range cfg.CustomTags {
tagFunctions[k] = v
}
for k, v := range cfg.CustomTags {
tagFunctions[k] = v
}
return tagFunctions