Esta página aún no está disponible en su idioma local. Estamos trabajando arduamente para agregar más versiones de idiomas. Gracias por tu apoyo.

Connecting to an Instance Using Go

Updated on 2023-11-21 GMT+08:00

This section describes how to connect to a GeminiDB Influx instance using the Go programming language.

Prerequisites

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)
    } 
}
Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback