(Feat): Initial Commit
Some checks failed
Build & Test / build-test (push) Has been cancelled
Build & Test / swagger-codegen-cli (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled

This commit is contained in:
2026-07-03 19:41:31 +05:30
commit 7e940c83a7
461 changed files with 45002 additions and 0 deletions

39
internal/util/fs.go Normal file
View File

@@ -0,0 +1,39 @@
// nolint:revive
package util
import (
"fmt"
"os"
"time"
)
// TouchFile creates an empty file if the file doesnt already exist.
// If the file already exists then TouchFile updates the modified time of the file.
// Returns the modification time of the created / updated file.
func TouchFile(absolutePathToFile string) (time.Time, error) {
_, err := os.Stat(absolutePathToFile)
if os.IsNotExist(err) {
file, err := os.Create(absolutePathToFile)
if err != nil {
return time.Time{}, fmt.Errorf("failed to create file: %w", err)
}
defer file.Close()
stat, err := file.Stat()
if err != nil {
return time.Time{}, fmt.Errorf("failed to stat file: %w", err)
}
return stat.ModTime(), nil
}
currentTime := time.Now().Local()
err = os.Chtimes(absolutePathToFile, currentTime, currentTime)
if err != nil {
return time.Time{}, fmt.Errorf("failed to change file time: %w", err)
}
return currentTime, nil
}