Go

Install

sh

  1. go get github.com/GreptimeTeam/greptimedb-client-go

Create a Client

go

  1. package example
  2. import (
  3. greptime "github.com/GreptimeTeam/greptimedb-client-go"
  4. "google.golang.org/grpc"
  5. "google.golang.org/grpc/credentials/insecure"
  6. )
  7. func InitClient() *greptime.Client {
  8. options := []grpc.DialOption{
  9. grpc.WithTransportCredentials(insecure.NewCredentials()),
  10. }
  11. // To connect a database that needs authentication, for example, those on Greptime Cloud,
  12. // `Username` and `Password` are needed when connecting to a database that requires authentication.
  13. // Leave the two fields empty if connecting a database without authentication.
  14. cfg := greptime.NewCfg("127.0.0.1").
  15. WithDatabase("public"). // change to your real database
  16. WithPort(4001). // default port
  17. WithAuth("", ""). // `Username` and `Password`
  18. WithDialOptions(options...). // specify your gRPC dail options
  19. WithCallOptions() // specify your gRPC call options
  20. client, err := greptime.NewClient(cfg)
  21. if err != nil {
  22. panic("failed to init client")
  23. }
  24. return client
  25. }

See Go SDK in reference to get more configurations.

Write Data

Please refer to write data.

Query Data

Please refer to Query data.