new-doxa-monorepo

This commit is contained in:
kankys committed 2026-08-07 09:48:59 +02:00
1 parent b4401527a3
commit 5eacbb0182
162 files changed
+21820 -2

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
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, &notes)
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)
}