func exec(db *sql.DB, query string, bindvars ...interface{}) sql.Result { var res sql.Result var err error if len(bindvars) > 0 { res, err = db.Exec(query, bindvars...) } else { res, err = db.Exec(query) } if err != nil { panic(fmt.Sprintf("Error running sql: %s %v", query, err)) } return res }
func query(db *sql.DB, query string, bindvars ...interface{}) *sql.Rows { var rows *sql.Rows var err error if len(bindvars) > 0 { rows, err = db.Query(query, bindvars...) } else { rows, err = db.Query(query) } if err != nil { panic(fmt.Sprintf("Error running sql: %s %v", query, err)) } return rows }