CI: Apply Go linter recommendations to "ai/tensorflow" package #5330

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-11-22 11:47:17 +01:00
parent b954de52e9
commit 75bc6d754c
10 changed files with 113 additions and 59 deletions

View File

@@ -6,11 +6,12 @@ func randomString(length int) string {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
result := make([]byte, length)
for i := range result {
result[i] = charset[rand.IntN(len(charset))]
result[i] = charset[rand.IntN(len(charset))] //nolint:gosec // pseudo-random is sufficient for non-cryptographic identifiers
}
return string(result)
}
// GetOne returns an arbitrary key-value pair from the map or nils when empty.
func GetOne[K comparable, V any](input map[K]V) (*K, *V) {
for k, v := range input {
return &k, &v
@@ -19,6 +20,7 @@ func GetOne[K comparable, V any](input map[K]V) (*K, *V) {
return nil, nil
}
// Deref returns the value of a pointer or a default when the pointer is nil.
func Deref[V any](input *V, defval V) V {
if input == nil {
return defval