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. }

5. cfg := greptime.NewCfg("<host>").
6. WithDatabase("<dbname>").
7. WithPort(4001).              // default port
8. WithAuth("<username>", "<password>").
9. WithDialOptions(options...). // specify your gRPC dail options
10. WithCallOptions()            // specify your gRPC call options

12. client, err := greptime.NewClient(cfg)
13. if err != nil {
14. panic("failed to init client")
15. }