我正在尝试使用 sql 模块在 go 中执行查询。


var from string = "2015-03-01 00:00:00"    

rows, err := db.Query("select time, val from table where " +

                              "time >= extract(epoch from timestamp with time zone $1)::int4 " +

                              "and time < extract(epoch from timestamp with time zone '2015-03-01 00:15:10')::int4 " +

                              "order by time asc",from)

但是我得到了错误


pq: syntax error at or near "$1"

如果我直接输入纪元值,那么查询将起作用,并且当我在没有任何变量的情况下尝试查询时,查询将起作用,即使用硬编码的查询。那么问题是什么?