need help assigning the returned type from client.WriteAPIBlocking.
var dbClient influxdb2.Client
var writeAPIx <????>
dbClient = influxdb2.NewClient(...
writeAPIx = dbClient.WriteAPIBlocking(...
The return for WriteAPIBlocking is (*api.WriteAPIBlocking).
Can you help me to declare the type for writeAPIx?
I can’t use :=, as I need to pass the value around - in and out of functions.
@kevinR. Thanks for using the InfluxDB Go client. api.WriteAPIBlocking is an interface and thus it is a reference by default. You can declare a variable simply: var writeAPIx api.WriteAPIBlocking
func InitWriting() {
var dbClient influxdb2.Client
var writeAPIx api.WriteAPIBlocking
dbClient = influxdb2.NewClient("http://localhost:8086","my-token")
writeAPIx = dbClient.WriteAPIBlocking("my-org","my-bucket")
go metricsWriter(writeAPIx)
}
func metricsWriter(writer api.WriteAPIBlocking) {
// gather and write data
}