Rewritten in go and python

This commit is contained in:
2024-11-06 01:25:27 +04:00
parent 9f22d9678d
commit d8449237bb
50 changed files with 3824 additions and 879 deletions

11
server/pkg/utils/env.go Normal file
View File

@@ -0,0 +1,11 @@
package utils
import "os"
func GetEnv(key, default_ string) string {
value := os.Getenv(key)
if value == "" {
return default_
}
return value
}

16
server/pkg/utils/file.go Normal file
View File

@@ -0,0 +1,16 @@
package utils
import "os"
func MakeDirIfNotExist(path string) error {
return os.MkdirAll(path, os.ModePerm)
}
func IsDirExist(path string) (bool, error) {
if _, err := os.Stat(path); err == nil {
return true, nil
} else if !os.IsNotExist(err) {
return false, err
}
return false, nil
}

View File

@@ -0,0 +1,20 @@
package utils
import (
"math"
"path/filepath"
"strconv"
)
func IsValidPath(path string) bool {
return filepath.IsAbs(path)
}
func IsUint32(value int) bool {
return value >= 0 && value <= math.MaxUint32
}
func IsInt(value string) bool {
_, err := strconv.Atoi(value)
return err == nil
}