On Mon, 3 Sep 2018, 13:03 'sebastian andersen' via golang-nuts, <
[email protected]> wrote:
> This code want's me to believe that I have not declared any of the
> variables that I am currently trying to declare:
>
> func deleteRow() {
> db, err := sql.Open("mysql", "root@/testshit")
> checkErr(err)
>
> // delete
> stmt, err = db.Prepare("delete from userinfo where uid=?")
> checkErr(err)
>
> res, err = stmt.Exec(id)
> checkErr(err)
>
> affect, err = res.RowsAffected()
> checkErr(err)
>
> fmt.Println(affect)
>
> db.Close()
> }
>
You need to use short assignment ":=" for variable that is not declared
previously.
In your case, "stmt, err = ..." should be " stmt, err := ..."
Tour about variable short assignment: https://tour.golang.org/basics/10
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.