Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"SQL Injection (Go's database integration is still the wild west)"

Is something like this prone to SQL injection ? I am very new to Go and still learning how to interact with databases (I am not a big fan of ORMs).

    stmt = "UPDATE users SET last_login = $1 WHERE id = $2"

    _, err = services.DB.ExecContext(ctx, stmt, time.Now(), id)


That is the correct approach.


That would only be vulnerable if the DB client is replacing your parameterized query with string concatenation under the hood.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: