I'm trying to reassign a pointer to a new value that's been passed on as func parameter, but once I step out of the function, the pointer has a nil value again.
I've stepped through the code and it seems to work until I step out of the function into the calling function where the passed on pointer still holds a NIL value.
func Prepare(db *sqlx.DB, stmt *sqlx.Stmt, query String) error {
res,err := db.PreparexStatement(context.Background(), query)
stmt = res
return err
}
I would expect the following to work:
func Boot(db *sqlx.DB, stmt *sqlx.Stmt, query String) {
err := Prepare(db, stmt, query)
if err != nil {
//handle
}
}
I'm still fairly new to GO, so I believe I fail to grasp a concept here. Any help would be greatly appreciated.