InfluxDB client for Go

Hi,

I already Googled to find answers related to the Go InfluxDB client. But I’m really confused as what to use as Go client. When trying to install the v2 (github.com/influxdata/influxdb/client/v2) gives problems/errors.

I found finally this: go get github.com/influxdata/influxdb1-client/v2
Can someone confirm if installing this Go package is al I need to interface with an InfluxDB from Go?

Many thanks.
Guy

Thats correct. Here is a code snippet for how to connect to InfluxDB:

import (
client “GitHub - influxdata/influxdb1-client: The old clientv2 for InfluxDB 1.x
)

func establishInfluxConnection(username string, password string, databaseURL string) *client.Client {
host, err := url.Parse(databaseURL)
if err != nil {
log.Fatal(err)
}

conf := client.Config{
	URL:      *host,
	Username: username,
	Password: password,
}
con, err := client.NewClient(conf)
if err != nil {
	log.Fatal(err)
}

return con

}

con := establishInfluxConnection(configuration.InfluxUsername, configuration.InfluxPassword, configuration.InfluxHost)