为什么不替换我的SQL占位符(使用Go pq)?

As per the docs, I'm doing this

var thingname string = "asdf";
var id int
err = database.QueryRow("SELECT id from things where thing = ?", thingname).Scan(&id)

but Postgres is saying

ERROR:  syntax error at end of input at character 41
STATEMENT:  SELECT id from things where thing = ?

I can't see that I'm doing much different to the demo code. I'm using pq.

The exact syntax is database dependent.

Use

err = database.QueryRow("SELECT id from things where thing = $1", thingname).Scan(&id)

Try this using $1 instead of ?:-

err = database.QueryRow("SELECT id from things where thing = $1", thingname).Scan(&id)