Go-CLI-Tool zum Konvertieren von CSV-Dateien in Excel (.xlsx), mit Mage-Build-System und Architektur-Dokumentation.
1.2 KiB
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\toccurrences in the first line. Falls back to;on error.
Key behaviors:
- Sheet names are truncated to 31 characters (Excel limit)
- Encoding
windows1252wraps the file reader with a Windows-1252 decoder csvReader.LazyQuotes = truefor 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— fromgit describe --tags --alwaysinternal/version.Commit— fromgit rev-parse --short HEADinternal/version.BuildDate— fromdate -u
Dependencies
github.com/xuri/excelize/v2— Excel file creation/manipulationgolang.org/x/text— Character encoding (Windows-1252 support)