Help Center/
GeminiDB/
GeminiDB Influx API/
Getting Started with GeminiDB Influx API/
Instance Connections/
Connecting to an Instance Using Program Code/
Connecting to an Instance Using Go
Updated on 2023-11-21 GMT+08:00
Connecting to an Instance Using Go
This section describes how to connect to a GeminiDB Influx instance using the Go programming language.
Prerequisites
- You have downloaded the client code from the InfluxDB open-source project website.
Example Code for Accessing an Instance Using a Non-SSL Connection
package main import ( "fmt" _ "github.com/influxdata/influxdb1-client" // this is important because of the bug in go mod client "github.com/influxdata/influxdb1-client/v2" ) func main(){ c, err := client.NewHTTPClient(client.HTTPConfig{ Addr: "http://ip:port", Username: "******", Password: "******", }) if err != nil { fmt.Println("Error creating InfluxDB Client: ", err.Error()) } q := client.NewQuery("select * from cpu","db0","ns") if response, err := c.Query(q); err == nil && response.Error() == nil { fmt.Println("the result is: ",response.Results) } }
Parent topic: Connecting to an Instance Using Program Code
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.