Go SDK

The GreptimeDB Go SDK uses gRPC to communicate with the database. For more information on how to use the SDK, please refer to the Go SDK documentation.

To connect to GreptimeCloud, using information below:

  • Host: <host>
  • Port: 4001
  • Database: <dbname>
  • Username: <username>
  • Password: <password>

The following code shows how to create a client.

go

  1. options := []grpc.DialOption{
  2. grpc.WithTransportCredentials(insecure.NewCredentials()),
  3. }
  4. cfg := greptime.NewCfg("<host>").
  5. WithDatabase("<dbname>").
  6. WithPort(4001).
  7. WithAuth("<username>", "<password>").
  8. WithDialOptions(options...). // specify your gRPC dail options
  9. WithCallOptions() // specify your gRPC call options
  10. client, err := greptime.NewClient(cfg)
  11. if err != nil {
  12. panic("failed to init client")
  13. }