ads

Tuesday, January 16, 2024

Show HN: Go 1.22 range functions with database/sql https://ift.tt/l4kLQHt

Show HN: Go 1.22 range functions with database/sql Hello HN! I published a package exploring how to use the experimental range functions coming to Go 1.22 with database/sql to stream values in and out of SQL databases. One interesting benefit of range functions I found is they enable automatic resource management (no risk of forgetting to close a sql.Rows, or missing a call to Err to check errors). The use of generics adds type safety and simplifies exchanging values between the Go application and the database. The resulting code is also quite efficient, the compiler can inline the call sites that create the range functions, which helps escape analysis and allow most values to be allocated on the stack. Let me know if you have any feedback, I hope it will be useful! https://ift.tt/jzsZdKt January 17, 2024 at 12:31AM

No comments:

Post a Comment