Базовый Readme, понятные переменные окружения

This commit is contained in:
set
2026-03-17 14:28:15 +02:00
parent e703ac22e6
commit 3c810407db
5 changed files with 84 additions and 31 deletions

View File

@@ -1,6 +1,9 @@
package utils
import "math/rand"
import (
"math/rand"
"strconv"
)
// Генерация случайной строки заданной длины
func RandomString(n int) string {
@@ -11,3 +14,14 @@ func RandomString(n int) string {
}
return string(b)
}
func AtoiOrDefault(s string, defaultValue int) int {
if s == "" {
return defaultValue
}
n, err := strconv.Atoi(s)
if err != nil {
return defaultValue
}
return n
}