I know my resultset will only have one row. But I don't know about columns. e.g.
func GetData(db *sql.DB, ent Entity, tableName, uniqueField string, value interface{}) error { query := fmt.Sprintf("SELECT * FROM %s WHERE %s = $1", tableName, uniqueField) row := db.QueryRow(query, value) columns := []string{} // columns, err := row.Columns() if err := row.Scan(ent.Pointers(columns)...); err != nil { return err } return nil } On Saturday, August 14, 2021 at 5:08:12 AM UTC-3 Tamás Gulácsi wrote: > It could, but what for? sql.Row is already a convenience wrapper for > I-know-I-want-only-one-row, > so you know what kind of data are you retrieving, but you know it's only > one row? > > daniel...@omie.com.br a következőt írta (2021. augusztus 13., péntek, > 19:04:24 UTC+2): > >> Yes i ever use Query() instead of QueryRow(). >> My doubt is more about the API design. >> If exists *sql.Row with Scan() method why not implements Columns() ? >> >> On Thursday, August 5, 2021 at 3:43:44 PM UTC-3 eli...@gmail.com wrote: >> >>> In what case do you find the need to call Columns() on a Row? Generally >>> if you have access to a Row, you also have access to a Rows, which does >>> have a Columns() method. >>> >>> Eli >>> >>> On Thu, Aug 5, 2021 at 10:34 AM Daniel da Silva <dop...@gmail.com> >>> wrote: >>> >>>> Hello guys! >>>> >>>> Why doesn't sql.Row implement the Columns() method? >>>> >>>> Thanks! >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "golang-nuts" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to golang-nuts...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/golang-nuts/1c521514-d267-456c-a66a-e56544965fd3n%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/golang-nuts/1c521514-d267-456c-a66a-e56544965fd3n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/aa0085f1-7057-40fb-9539-3c133331e152n%40googlegroups.com.