Skip to content

Instantly share code, notes, and snippets.

View lundha's full-sized avatar

Martin Lund Haug lundha

View GitHub Profile
@lundha
lundha / selectForUpdate.go
Created November 2, 2023 08:41
SELECT ... FOR UPDATE
package main
import (
"context"
"database/sql"
"fmt"
"log"
"sort"
"github.com/jmoiron/sqlx"
@lundha
lundha / gist:d592bd11f1c490999e3bcdb272e114bc
Last active October 17, 2023 18:34
Gorm v2.0 cleanup hook
func DeleteCreatedEntities(db *gorm.DB) func() {
hookName := "cleanupHook"
type entity struct {
table string
key string
value interface{}
}
var entries []entity