Go SDK

The GreptimeDB Go ingester library utilizes gRPC for writing data to the database. For how to use the library, please refer to the Go library 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). // default port
  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. }