refactor: simplify codebase (-209 lines)

This commit is contained in:
Mathis Maquenne
2026-03-01 21:55:42 +01:00
parent cd45c3f40a
commit 08b608ec80
31 changed files with 389 additions and 598 deletions
+4 -6
View File
@@ -2,6 +2,7 @@ package fileutil
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"os"
@@ -18,13 +19,11 @@ func EnsureDir(path string) error {
if !info.IsDir() {
return fmt.Errorf("file already exists at %s", path)
}
return nil
}
func FileExists(path string) bool {
info, err := os.Stat(path)
return err == nil && !info.IsDir()
}
@@ -32,7 +31,6 @@ func DeleteFile(path string) error {
if !FileExists(path) {
return nil
}
return os.Remove(path)
}
@@ -43,10 +41,10 @@ func GetFileHash(path string) (string, error) {
}
defer file.Close()
hash := sha256.New()
if _, err := io.Copy(hash, file); err != nil {
h := sha256.New()
if _, err := io.Copy(h, file); err != nil {
return "", err
}
return fmt.Sprintf("%x", hash.Sum(nil)), nil
return hex.EncodeToString(h.Sum(nil)), nil
}