mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
CI: Apply Go linter recommendations to "ai/tensorflow" package #5330
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user