package main import ( "encoding/json" "fmt" "os" "path/filepath" "time" ) type Note struct { ID int64 `json:"id"` Name string `json:"name"` Content string `json:"content"` Tags []string `json:"tags"` Folder string `json:"folder"` CreatedAt time.Time `json:"created_at"` ModifiedAt time.Time `json:"modified_at"` } func getStoragePath() string { home, err := os.UserHomeDir() if err != nil { return "doxa_notes.json" // fallback do aktuálního adresáře } configDir := filepath.Join(home, ".doxa-cli") // Vytvoření složky, pokud neexistuje if _, err := os.Stat(configDir); os.IsNotExist(err) { os.MkdirAll(configDir, 0755) } return filepath.Join(configDir, "doxa_notes.json") } func loadNotes() []Note { path := getStoragePath() file, err := os.ReadFile(path) if err != nil { return []Note{} } var notes []Note json.Unmarshal(file, ¬es) return notes } func saveNotes(notes []Note) { path := getStoragePath() data, err := json.MarshalIndent(notes, "", " ") if err != nil { fmt.Println("Chyba při ukládání dat:", err) return } os.WriteFile(path, data, 0644) }