EExcel 丞燕快速查詢2

EExcel 丞燕快速查詢2
EExcel 丞燕快速查詢2 https://sandk.ffbizs.com/

golang []map[string]interface{} sqlx BUT

Golang often us []interface{} or map[string]interface{}

sqlx.Queryx Alternate Scan Types



rows, err := db.Queryx("SELECT * FROM place")
for rows.Next() {
  // cols is an []interface{} of all of the column results
  cols, err := rows.SliceScan()
}

rows, err := db.Queryx("SELECT * FROM place")
for rows.Next() {
  results := make(map[string]interface{})
  err = rows.MapScan(results)
}

So
func Sqlselectall(db1 *sqlx.DB, table string) []map[string]interface{} {

  rows, err := db1.Queryx("SELECT * FROM  " + table)
  if err != nil { }

  results := []map[string]interface{}{}
  for rows.Next() {
    result := make(map[string]interface{})
    err = rows.MapScan(result)
    results = append(results, result)
  }

  return results
}


BUT  results to json use c.JSON(http.StatusOK, results) get warning value


https://stackoverflow.com/questions/39391437/merge-two-or-more-mapstringinterface-types-into-one-in-golang