From 7ff01df9f72a305a7ff3d8cbfe44e0055038992d Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Tue, 23 May 2023 16:29:45 -0500 Subject: [PATCH] fix(client-library): add imports in Go sample code (#4952) --- .../reference/client-libraries/v2/go.md | 19 +++++++++++++++---- .../reference/client-libraries/v2/go.md | 10 ++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/content/influxdb/cloud-dedicated/reference/client-libraries/v2/go.md b/content/influxdb/cloud-dedicated/reference/client-libraries/v2/go.md index 56df1e314..4d46484ca 100644 --- a/content/influxdb/cloud-dedicated/reference/client-libraries/v2/go.md +++ b/content/influxdb/cloud-dedicated/reference/client-libraries/v2/go.md @@ -54,7 +54,7 @@ Use the Go library to write and query data from InfluxDB. ```go bucket := "example-database" - org := "example-org" + org := "ignored" token := "example-token" // Store the URL of your InfluxDB instance url := "https://cluster-id.influxdb.io" @@ -98,12 +98,22 @@ Use the Go library to write data to InfluxDB. ### Complete example write script ```go +package main + +import ( + "context" + "fmt" + "time" + + "github.com/influxdata/influxdb-client-go/v2" +) + func main() { bucket := "example-database" - org := "example-org" + org := "ignored" token := "example-token" // Store the URL of your InfluxDB instance - url := "http://localhost:8086" + url := "https://cluster-id.influxdb.io" // Create new client with default option for server url authenticate by token client := influxdb2.NewClient(url, token) // User blocking write client for writes to desired bucket @@ -120,7 +130,8 @@ func main() { } ``` ## Query data from InfluxDB with Go -The InfluxDB v2 Go client cannot query InfluxDB Cloud Dedicated. + +The InfluxDB v2 Go client can't query InfluxDB Cloud Dedicated. To query your dedicated instance, use the [Go Flight SQL client](https://pkg.go.dev/github.com/apache/arrow/go/v12/arrow/flight/flightsql). For an example, see [Get started querying data](/influxdb/cloud-dedicated/get-started/query/?t=Go#execute-an-sql-query). diff --git a/content/influxdb/cloud-serverless/reference/client-libraries/v2/go.md b/content/influxdb/cloud-serverless/reference/client-libraries/v2/go.md index c7a37e7c7..ce59be31d 100644 --- a/content/influxdb/cloud-serverless/reference/client-libraries/v2/go.md +++ b/content/influxdb/cloud-serverless/reference/client-libraries/v2/go.md @@ -98,6 +98,16 @@ Use the Go library to write data to InfluxDB. ### Complete example write script ```go +package main + +import ( + "context" + "fmt" + "time" + + "github.com/influxdata/influxdb-client-go/v2" +) + func main() { bucket := "example-bucket" org := "example-org"