A developer reported issues connecting to DataStax Astra with the gocql driver using the sample code in How to connect to Astra with the gocql driver.
When running the sample code as-is, the output is:
$ ./astra_gocql_connect According to independent.co.uk, the top 5 most liveable cities in 2019 were: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x148 pc=0x66f8d7] goroutine 1 [running]: github.com/gocql/gocql.(*Query).defaultsFromSession(0xc000108120) /home/ubuntu/go/src/github.com/gocql/gocql/session.go:842 +0x37 github.com/gocql/gocql.(*Session).Query(0x0, 0x706528, 0x58, 0x0, 0x0, 0x0, 0x0) /home/ubuntu/go/src/github.com/gocql/gocql/session.go:383 +0xb2 main.main() /home/ubuntu/astra_gocql_connect.go:48 +0x6dc
With some error handling added when creating the session:
session, err := _cluster.CreateSession() if err != nil { panic(err) }
the output looks like:
$ ./astra_gocql_connect panic: gocql: unable to create session: unable to discover protocol version: gocql: no response to connection startup within timeout goroutine 1 [running]: main.main() /home/ubuntu/astra_gocql_connect.go:43 +0x9e7