If you want to avoid boilerplate and keep the lightest weight possible,
you could have a look at the approach I took recently when I
added SQL support in my serialization format, greenpack. 

See here: (only supports MariaDB/MySQL syntax at the moment)

https://github.com/glycerine/greenpack?tab=readme-ov-file#december-2024-sql-support

https://github.com/glycerine/greenpack/blob/master/testdata/_sqldemo_gen.go

The code-generation will generate the
SQL create, insert, and select statements corresponding to each struct
in the files that have //go:generate greenpack -sql mariadb
in them.

This is minimal and ultra simple but still saves manually writing tedious 
boilerplate.
It keeps your fields received always aligned with your select statements.
It is appropriate if your Go code is your source-of-truth/starting point.

The other packages I looked at (ORMs, etc) seem to want
to take the database schema as the starting point, and create Go code from 
that.

That's a reasonable approach, but not what I needed.

Enjoy,
Jason

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/2dc9d305-1a5a-47f0-8172-7a942df2b3efn%40googlegroups.com.

Reply via email to