A lightweight Go library for scanning SQL rows directly into structs, slices, and primitive types.
Scan is a Go library that maps SQL query results directly to Go structs, slices, and primitive types. It eliminates the need for manual row iteration and field assignment when working with the standard `database/sql` package, reducing boilerplate code and potential errors.
Go developers who write raw SQL or use query builders like Squirrel and want a lightweight, non-intrusive way to map database results to structured data without adopting a full ORM.
Scan offers a focused alternative to heavier libraries like sqlx by providing efficient row scanning with minimal dependencies, strict scanning options for safety, and utilities that integrate seamlessly with existing SQL workflows.
Tiny lib to scan SQL rows directly to structs, slices, and primitive types
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically scans SQL rows into Go structs, slices, and primitive types, eliminating manual iteration and field assignment boilerplate, as shown in the README examples for multiple rows and single rows.
Provides RowStrict and RowsStrict functions that only map columns using explicit db struct tags, preventing accidental field mismatches and enhancing code reliability.
Handles nested struct fields with column name mapping using dot notation (e.g., 'person.id'), allowing complex data structures to be scanned seamlessly, demonstrated in the README's nested struct example.
Uses sync.Map to cache struct field reflections for improved scanning speed, with benchmarks provided in the README showing efficient performance for various scanning scenarios.
The project is declared complete with no updates since 2021, meaning it lacks ongoing support, bug fixes, or compatibility with newer Go versions and database drivers.
Relies on runtime reflection for scanning, which, even with caching, can introduce performance overhead compared to compile-time approaches like code generation, potentially affecting high-load applications.
Focuses solely on scanning; it doesn't provide ORM features like migrations, relationships, or query building, requiring additional libraries for a comprehensive database solution.