21 lines
333 B
Go
21 lines
333 B
Go
package helper
|
|
|
|
import (
|
|
"hash/fnv"
|
|
"math"
|
|
"os"
|
|
)
|
|
|
|
func FileExists(filePath string) bool {
|
|
_, err := os.Stat(filePath)
|
|
return err == nil || os.IsExist(err)
|
|
}
|
|
|
|
func HashMod(hashStr string) int {
|
|
hash := fnv.New32a()
|
|
_, _ = hash.Write([]byte(hashStr))
|
|
|
|
hashValue := hash.Sum32()
|
|
return int(math.Mod(float64(hashValue), 32))
|
|
}
|