Each rule now has one owning contract; others point to it: validation and multi-step rules live in forms-validation (modal-workflows references them), pagination metadata lives in go-api (table-management references it), the async task flow lives in go-background-tasks (go-api references it), backup git-safety checks live in backup-management (go-database references it). Remove the leftover Vapor/Aqua baseline mention and stale kit/patterns paths, compress the batch-file-upload ADR narrative, and drop content-free pattern READMEs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
33 lines
945 B
Markdown
33 lines
945 B
Markdown
# Import / Export Pattern Notes
|
|
|
|
This file keeps examples. The normative rules live in `contract.md`.
|
|
|
|
## Export Handler Sketch
|
|
|
|
```go
|
|
func ExportCSV(c *gin.Context) {
|
|
c.Header("Content-Type", "text/csv; charset=utf-8")
|
|
c.Header("Content-Disposition", `attachment; filename="export.csv"`)
|
|
c.Writer.Write([]byte{0xEF, 0xBB, 0xBF})
|
|
|
|
w := csv.NewWriter(c.Writer)
|
|
w.Comma = ';'
|
|
w.Write([]string{"ID", "Name", "Price"})
|
|
|
|
err := svc.StreamRows(ctx, filters, func(row Row) error {
|
|
return w.Write([]string{row.ID, row.Name, formatPrice(row.Price)})
|
|
})
|
|
w.Flush()
|
|
if err != nil {
|
|
slog.Error("csv export failed mid-stream", "err", err)
|
|
}
|
|
}
|
|
```
|
|
|
|
## Locale Notes
|
|
|
|
- BOM avoids broken UTF-8 in Excel on Windows.
|
|
- Semicolon avoids single-column imports in RU/EU locales.
|
|
- Decimal comma keeps numbers numeric in Excel.
|
|
- `DD.MM.YYYY` is preferred over ISO dates for user-facing spreadsheet exports.
|