Golang sqlx library transaction error

1.golang reported an error
2 when using sqlx"s transaction. The code is as follows

package main

import (
    "log"
    _ "github.com/lib/pq" // PostgreSQL
    "github.com/jmoiron/sqlx"
    "github.com/lib/pq"
    "fmt"
)

type Test struct {
    Id   int           `json:"id" db:"id" form:"id"`
    Name string        `json:"name" db:"name" form:"name"`
    Role pq.Int64Array `json:"role" db:"role" form:"role"`
}

func main() {
    db, err := sqlx.Connect("postgres", "user=postgres password=*** dbname=*** sslmode=disable")
    if err != nil {
        log.Panicln(err)
    }
    defer db.Close()
    db.SetMaxOpenConns(1)
    tx, err := db.Beginx()
    test := Test{Name: "name", Role: []int64{1, 2, 3}}
    _, err1 := tx.NamedQuery(`INSERT  INTO test(name,role) VALUES (:name,:role)returning id`, test)
    fmt.Println(err1)
    _, err1 = tx.NamedQuery(`INSERT  INTO test(name,role) VALUES (:name,:role)returning id`, test)
    fmt.Println(err1)
    _, err1 = tx.NamedQuery(`INSERT  INTO test(name,role) VALUES (:name,:role)returning id`, test)
    fmt.Println(err1)
    _, err1 = tx.NamedQuery(`INSERT  INTO test(name,role) VALUES (:name,:role)returning id`, test)
    fmt.Println(err1)
    _, err1 = tx.NamedQuery(`INSERT  INTO test(name,role) VALUES (:name,:role)returning id`, test)
    fmt.Println(err1)
    tx.Commit()
}

3. The output is as follows:

<nil>
pq: unexpected Parse response "D"
driver: bad connection
driver: bad connection
driver: bad connection

Process finished with exit code 0

4. It"s okay to replace namedquery () with namedexec (), but I want to get the primary key returned by the first statement before I can do the rest.

5. Ask the great god for an answer, thank you


do not directly see the fault, and do not bother to write code verification, try to guess

1. Remove values () returning id from
2 and sql of db.SetMaxOpenConns (1), and add a space values () returing id

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e44fe3-4c204.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e44fe3-4c204.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?