How knadh/goyesql works
Main Components
a) Input Layer:
• SQL File Reader Component
• Raw SQL Query Files (*.sql)
• Support for both file system and embedded files (stuffbin)
b) Parser Components:
• Scanner Component (based on scanner.go)
• Line Parser Component (based on parser_line.go)
• Query Tag Parser
c) Query Management Layer:
• Query Map Storage
• Tag Storage System
• Query Preparation System
d) Integration Layer:
• SQL/SQLx Connection Handler
• Statement Preparation System
• Struct Scanner Component
Flow Representation
Start at the top with two parallel input paths:
[SQL Files] ----→ [File Reader]
[Embedded Binary] ----→ [Bytes Reader]
• ↓
• [Scanner]
• ↓
• [Line Parser] ←→ [Tag Parser]
• ↓
[Query Map Builder]
• ↓
[Statement Preparation]
• ↓
[Struct Scanner]
Important Details
a) Query Processing:
• How queries are parsed and separated
• Tag extraction and storage
• Query preparation flow
b) Integration Points:
• Connection with sql.DB/sqlx.DB
• Prepared statement creation
• Struct scanning capability
Notes Section
A notes section explaining:
• The project's compatibility break from original goyesql
• Support for both sql and sqlx
• Embedded file support through stuffbin
Remember to emphasize:
• The separation of concerns between parsing and preparation
• The flexibility of the tag system
• The integration capabilities with both sql and sqlx
• The support for both file-based and embedded queries