Shriram Sunder

10/05/2022, 11:57 PM
The documentation confirms this, then how do I concurrently insert data into the database? Isn't that the main benefit of using Go? The code below is executed inside a goroutine, there are no senders that are shared between goroutines, each goroutine gets it's own sender... so this should technically work (as it's not mentioned within the documentation). And yet I get the following error:
runtime error: invalid memory address or nil pointer dereference
// Send the data to QDB, if response is not empty
	if res.Results != nil {
		// Connect to QDB and get sender
		sender, _ := qdb.NewLineSender(ctx)

		for _, v := range res.Results {
			err := sender.Table("aggs").
				Symbol("ticker", res.Ticker).
				StringColumn("timespan", "minute").
				Int64Column("multiplier", int64(1)).
				Float64Column("open", v.O).
				Float64Column("high", v.H).
				Float64Column("low", v.L).
				Float64Column("close", v.C).
				Float64Column("volume", v.V).
				Float64Column("vw", v.Vw).
				Float64Column("n", float64(v.N)).
				At(ctx, time.UnixMilli(int64(v.T)).UnixNano())
		// Make sure the sender is flushed
		err = sender.Flush(ctx)

		// Close the sender.
		err = sender.Close()