[hw-4] add postgres db

This commit is contained in:
Никита Шубин
2025-06-26 12:08:46 +00:00
parent 3ebaad5558
commit 77ed9fcf85
46 changed files with 1582 additions and 369 deletions

View File

@@ -0,0 +1,19 @@
package tools
import (
"fmt"
"math"
)
func SafeCastInt64ToUInt32(num int64) (uint32, error) {
if num < 0 {
return 0, fmt.Errorf("tried casting signed negative number to unsigned number")
}
if num > math.MaxUint32 {
return 0, fmt.Errorf("tried casting larger number than uint32 can store")
}
// the bounds are checked, and cast should be safe.
return uint32(num), nil // #nosec G115
}