Fix possible panic (#34508)
Some checks are pending
release-nightly / nightly-docker-rootful (push) Waiting to run
release-nightly / nightly-docker-rootless (push) Waiting to run
release-nightly / nightly-binary (push) Waiting to run

This commit is contained in:
Lunny Xiao
2025-05-22 05:59:42 -07:00
committed by GitHub
parent 0d1d57c5bf
commit 06ccda06c4
3 changed files with 65 additions and 25 deletions

13
modules/util/map.go Normal file
View 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
}