'invalid memory address' error with go-mssql -


i'm having issue can't seem resolve, due inexperience go. have following code working on 1 server, not on another. here code:

// build out connection string database, , open connection database. connstring := fmt.sprintf("server=%s;user id=%s;password=%s;port=%d", *server, *user, *password, *port) if *debug { fmt.printf(" connstring:%s\n", connstring) } db, err = sql.open("mssql", connstring) if err != nil { log.fatal("open connection failed:", err.error()) } err = db.ping() if err != nil {     fmt.println("cannot connect: ", err.error())     return }  rows, _ := db.query( "select zip zip_rural zip = ?", zipcode[0:5] ) defer rows.close()  if !rows.next() {     acreagerequirement = .5 } 

on line reads if !rows.next() following error:

panic: runtime error: invalid memory address or nil pointer dereference panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x20 pc=0x477918] 

this same code works fine on server, running go version 1.4.2 on both machines. have feeling have bad syntax somewhere in here, have no idea real problem is. call db.exec within same file works fine, leads me believe database connection fine, reason db.query not executing correctly.

there error db.query. check error , if not nil, assume rows nil. i.e. calling rows.next() segfault. if display error, find out issue is.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -