4 ms·
With defers and named return values, it is actually possible to alter the return value inside of a defer. I had to do this recently to properly log an error (to
by aktau 12y ago
With defers and named return values, it is actually possible to alter the return value inside of a defer. I had to do this recently to properly log an error (to abort in the calling code). Also to do with database operations of course:
https://github.com/aktau/gomig/blob/a63d309848907a72782dd94ef7e2cb16c254e89b/db/postgres/pg_db_executor.go https://github.com/aktau/gomig/blob/a63d309848907a72782dd94e...
It's not the prettiest, but I needed it fixed soon. Will refactor later :).
Read about it here as well: http://blog.golang.org/defer-panic-and-recover http://blog.golang.org/defer-panic-and-recover