go使用Query从postgresql中读取数据失败

调用Query函数获取pgsql中的多行数据失败,一行数据都没有读到,debug之后看到返回的*sql.rows类型的变量中提示如下,

img

数据库中有十一列数据,如下所示

img

这是我的代码:

func Acenroll(w http.ResponseWriter, r *http.Request) {
    sqlStr := `SELECT * FROM acinfo ` //sql语句
    info, e := db.Query(sqlStr)  //查询数据库中的数据
    if e != nil {
        panic(e.Error())
    }
    defer info.Close()

    var activityinfo []string
//debug的时候发现,这个for循环被跳过了
    for info.Next() {
        var (
            acname    string
            bgdate    pgtype.Date
            bgtime    time.Time
            edate     pgtype.Date
            etime     time.Time
            acplace   string
            accontext string
            acpeople  float64
            mg        string
            phone     string
            quest     string
        )
        info.Scan(&acname, &bgdate, &bgtime, &edate, &etime, &acplace, &accontext, &acpeople, &mg, &phone, &quest)
        activityinfo = append(activityinfo, fmt.Sprintf(`{ "ActivityName": %s,BeginDate: %v,BeginTime: %v,EndDate: %v,
        EndTime: %v,
        ActivityPlace: %s,
        ActivityContext: %s,
        ActivityPeople: %f,
        Manager: %s,
        PhoneNumber:%s,
        Quest: %s,}`, acname, bgdate, bgtime, edate, etime, acplace, accontext, acpeople, mg, phone, quest))

    }
    
    backmsg = []byte(fmt.Sprintf(`[%s]`, strings.Join(activityinfo, ",")))
    resp(w)

}

你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答


本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。


因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。