可以从Golang中的sql.Rows获取SQL查询字符串吗?

I have the following code:

selectPart := "id, user_id, date, time, minutes, details, created_at, updated_at, project_id"
sqlQuery := fmt.Sprintf("SELECT %s FROM time_entries WHERE user_id = $1 AND date >= $2 and date <= $3", selectPart)

var rows *sql.Rows
var err error

if project == nil {
    rows, err = DB.Query(sqlQuery, user.ID, formatDate(from), formatDate(to))
} else {
    rows, err = DB.Query(sqlQuery + " AND project_id = $4", user.ID, formatDate(from), formatDate(to), project.ID)
}

The resulting rows structure is empty. I suppose it is because the interpolation of data is wrong. I am using PostgreSQL. Can I somehow get an SQL string from the rows instance?

Can I somehow get an SQL string from the rows instance?

No. This is easily answered by reading the documentation. Rows has no exported fields, and has only the following methods:

type Rows
    func (rs *Rows) Close() error
    func (rs *Rows) ColumnTypes() ([]*ColumnType, error)
    func (rs *Rows) Columns() ([]string, error)
    func (rs *Rows) Err() error
    func (rs *Rows) Next() bool
    func (rs *Rows) NextResultSet() bool
    func (rs *Rows) Scan(dest ...interface{}) error

I have to wonder why you would want this... you already know what query was used.