csv2excel/docs/architecture.md
Oliver Jakoubek 26b874674f feat: initialer Commit des csv2excel CLI-Tools
Go-CLI-Tool zum Konvertieren von CSV-Dateien in Excel (.xlsx),
mit Mage-Build-System und Architektur-Dokumentation.
2026-03-05 10:14:52 +01:00

1.2 KiB

Architecture

Overview

Single-file tool — entire application logic lives in main.go.

  • main(): Parses flags (-sep, -enc, -o), iterates over input CSV files, creates one Excel sheet per file using the filename (without extension) as the sheet name, writes all rows, saves the output .xlsx.
  • detectDelimiter(): Auto-detects the CSV delimiter by counting ;, ,, and \t occurrences in the first line. Falls back to ; on error.

Key behaviors:

  • Sheet names are truncated to 31 characters (Excel limit)
  • Encoding windows1252 wraps the file reader with a Windows-1252 decoder
  • csvReader.LazyQuotes = true for tolerance with malformed CSV files
  • The first sheet renames "Sheet1"; subsequent sheets are created fresh

Version Injection

Version info is injected at build time via ldflags from git tags:

  • internal/version.Version — from git describe --tags --always
  • internal/version.Commit — from git rev-parse --short HEAD
  • internal/version.BuildDate — from date -u

Dependencies

  • github.com/xuri/excelize/v2 — Excel file creation/manipulation
  • golang.org/x/text — Character encoding (Windows-1252 support)