flawopen.com/SQL Injection in Go/GORM
Only when you pass placeholders and args separately. It executes exactly the query text you give it, with no awareness of where that text came from.
db.Raw(fmt.Sprintf( "SELECT * FROM users WHERE id = %s", userID, )).Scan(&user)
db.Raw( "SELECT * FROM users WHERE id = ?", userID, ).Scan(&user)
GORM's chainable query builder (db.Where(...).First(&user)) parameterizes automatically and needs no special care. Raw() is a deliberate escape hatch for queries the builder can't express — it stays safe only if you never build the query string yourself with fmt.Sprintf first.
grep -rn "\.Raw(fmt.Sprintf" --include="*.go" .
Yes — Where(), First(), and similar methods parameterize automatically regardless of the value's content.