mirror of
https://github.com/go-gitea/gitea
synced 2025-07-11 21:17:19 +00:00
Fix possible panic (#34508)
This commit is contained in:
13
modules/util/map.go
Normal file
13
modules/util/map.go
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package util
|
||||
|
||||
func GetMapValueOrDefault[T any](m map[string]any, key string, defaultValue T) T {
|
||||
if value, ok := m[key]; ok {
|
||||
if v, ok := value.(T); ok {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return defaultValue
|
||||
}
|
Reference in New Issue
Block a user