Want to run an example? Follow the instructions below and change the commands based on which example you want to run, etc.
You can copy/paste the examples in any of these subfolders into a local file. You can also just use curl:
# Download an example. Replace /tables/typed/ with whatever example you want to download.
curl -L https://raw.githubusercontent.com/datastax/astra-db-go/main/examples/tables/typed/main.go -o main.goNext, initialize a go module using go mod init and get dependencies (you can use go mod tidy):
# Initialize a go module
go mod init github.com/example/module
# Get dependencies
go mod tidyCreate a .env file with the following values:
ASTRA_DB_API_ENDPOINT="https://my-database-id-my-region.apps.astra.datastax.com"
ASTRA_DB_APPLICATION_TOKEN="AstraCS:myToken"If you have the Astra CLI installed, you can have it create the .env file for you:
# Replace <db_name> with the name of your database
astra db create-dotenv <db_name> --preset data_api_client You can now run the example and interact with your database:
# Run the example
go run .