chore: splitting monolith into packages

This commit is contained in:
2026-04-02 17:22:55 +02:00
parent 3d61c78c35
commit be1dd05d9b
9 changed files with 171 additions and 116 deletions

29
utils/write_backlog.go Normal file
View File

@@ -0,0 +1,29 @@
package utils
import (
"encoding/json"
"errors"
"os"
"gotask-cli/models"
)
const tempPath string = "./tasks.save"
func SaveBacklog(backlog []models.Task, path string) {
if _, err := os.Stat(tempPath); err == nil {
err = os.Remove(tempPath)
} else if errors.Is(err, os.ErrNotExist) {
} else {
Check(err)
os.Exit(1)
}
f, err := os.Create(tempPath)
Check(err)
defer f.Close()
backlogJSON, _ := json.MarshalIndent(backlog, "", "\t")
f.Write(backlogJSON)
err = os.Rename(tempPath, path)
Check(err)
}