Each subdirectory contains a complete program for one Databricks Go SDK task. Choose the example closest to what you want to build, then copy it or run it from this directory.
All programs use the examples build tag. Include it when running one:
go run -tags=examples ./time_types| Program | What it demonstrates | Required setup |
|---|---|---|
authentication/resolution |
Create a client with automatic credential resolution | A profile or authentication environment variables (see below) |
authentication/m2m |
Construct and pass OAuth M2M credentials explicitly | DATABRICKS_HOST, DATABRICKS_CLIENT_ID, and DATABRICKS_CLIENT_SECRET |
authentication/custom |
Implement auth.Credentials for an external token provider |
Set workspaceHost in the program and provide EXTERNAL_ACCESS_TOKEN |
client_options |
Set a profile, logger, and request timeout | A Databricks profile |
pagination |
Iterate across pages and stop after enough results | A profile or authentication environment variables |
error_handling |
Inspect the code, HTTP status, and message of an API error | A profile or authentication environment variables |
field_masks |
Build an update with a typed field mask, including a oneof path and a field to clear | None |
oneofs |
Construct and inspect mutually exclusive oneof variants | None |
time_types |
Convert SDK timestamp and duration values | None |
For examples that use a workspace, install the Databricks CLI, then log in and select the profile explicitly:
databricks auth login --host https://<workspace-host> --profile SDK_EXAMPLES
DATABRICKS_CONFIG_PROFILE=SDK_EXAMPLES go run -tags=examples ./paginationAlternatively, provide credentials through environment variables:
DATABRICKS_HOST=https://<workspace-host> \
DATABRICKS_CLIENT_ID=<service-principal-client-id> \
DATABRICKS_CLIENT_SECRET=<service-principal-client-secret> \
go run -tags=examples ./paginationThe client_options example passes the profile directly as a client option:
go run -tags=examples ./client_options -profile SDK_EXAMPLES