Populated CLI with initial GO

This commit is contained in:
Lucas
2025-12-14 21:01:12 -08:00
parent d491fbd1fe
commit bfcf8d271b
10 changed files with 296 additions and 2 deletions

29
cli/new/append.go Normal file
View File

@@ -0,0 +1,29 @@
package data
import (
"encoding/json"
"os"
"definitive-opensource/models"
)
func AppendApplication(app models.Application) error {
file, err := os.ReadFile("applications.json")
if err != nil {
return err
}
var apps []models.Application
if err := json.Unmarshal(file, &apps); err != nil {
return err
}
apps = append(apps, app)
out, err := json.MarshalIndent(apps, "", " ")
if err != nil {
return err
}
return os.WriteFile("applications.json", out, 0644)
}