-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Init Golang SDK * search table * examples contrinued * delete snippets * Add python sdk schema edit references (#167) * add python sdk schema edit references * Update 040-SDK/020-Python/020-examples.mdx Co-authored-by: Philip Krauss <[email protected]> * Update 040-SDK/020-Python/020-examples.mdx Co-authored-by: Philip Krauss <[email protected]> * Update 040-SDK/020-Python/020-examples.mdx Co-authored-by: Philip Krauss <[email protected]> * Update 040-SDK/020-Python/020-examples.mdx Co-authored-by: Philip Krauss <[email protected]> * Update 040-SDK/020-Python/020-examples.mdx Co-authored-by: Philip Krauss <[email protected]> * Update 020-examples.mdx --------- Co-authored-by: Philip Krauss <[email protected]> * Point GH actions to FE (#168) * fix missing commas (#169) * Fix pricing docs URL (#170) rate limiting URL was pointing to an old docs page. * add updates for api docs (#165) * add updates for api docs * rewording * Update 060-Rest-API/010-authentication.mdx Co-authored-by: Kostas Botsas <[email protected]> * Update 060-Rest-API/020-contexts.mdx Co-authored-by: Kostas Botsas <[email protected]> * Update 010-authentication.mdx * links * update lint * update heading * update heading --------- Co-authored-by: Kostas Botsas <[email protected]> * Vercel deploys via github action (#173) * clarify Postman Bearer Token (#175) * clarify Postman Bearer Token * Update 060-Rest-API/020-contexts.mdx Co-authored-by: joan-ing <[email protected]> * reword * Update preview.yml * Update preview.yml --------- Co-authored-by: joan-ing <[email protected]> Co-authored-by: Alexis Rico <[email protected]> * Update sparse-checkout in workflows (#176) * Clarify main branch in Workflow (#178) * Clarify main used in Workflow * Update 040-workflow.mdx reword * Update 040-workflow.mdx reword 2 * Update docs for search change (#177) Signed-off-by: Alexis Rico <[email protected]> * more create examples * replace tabs with spaces * align var names * fix bulk insert example * one more * linting * update samples * one more update example * vector search examples * ask samples * trx snippet * update numeric ops * overview page * change alert to warning * Update 040-SDK/030-Go/010-overview.mdx Co-authored-by: joan-ing <[email protected]> * Update 040-SDK/030-Go/010-overview.mdx Co-authored-by: joan-ing <[email protected]> * Update 020-Getting-started/040-workflow.mdx Co-authored-by: joan-ing <[email protected]> * Update 020-Getting-started/040-workflow.mdx Co-authored-by: joan-ing <[email protected]> * Update 020-Getting-started/040-workflow.mdx Co-authored-by: joan-ing <[email protected]> * Update 040-SDK/020-Python/020-examples.mdx Co-authored-by: joan-ing <[email protected]> * add search items * Update 040-SDK/030-Go/010-overview.mdx Co-authored-by: joan-ing <[email protected]> * make linter happy * Update 040-SDK/030-Go/010-overview.mdx Co-authored-by: joan-ing <[email protected]> * Apply suggestions from code review Co-authored-by: joan-ing <[email protected]> * indent * add search skel * indent * add response struct * linter * Apply suggestions from code review Co-authored-by: joan-ing <[email protected]> * add install --------- Signed-off-by: Alexis Rico <[email protected]> Co-authored-by: Kostas Botsas <[email protected]> Co-authored-by: Dave Snider <[email protected]> Co-authored-by: joan-ing <[email protected]> Co-authored-by: Richard Gill <[email protected]> Co-authored-by: Alexis Rico <[email protected]>
- Loading branch information
1 parent
a48b8a4
commit edf0a00
Showing
11 changed files
with
770 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
title: Xata SDK for Go | ||
navTitle: SDK overview | ||
keywords: ['go', 'golang', 'sdk'] | ||
description: Get to know Xata using Go | ||
slug: sdk/go/overview | ||
published: true | ||
--- | ||
|
||
<Alert status="warning"> | ||
The Go SDK is currently in *alpha*. This means that it does not include all endpoints and is subject to potential | ||
breaking changes before reaching its `1.0.0` stable General Availability (GA) release. | ||
</Alert> | ||
|
||
The Go SDK is available on GitHub: https://github.com/xataio/xata-go | ||
|
||
## Install | ||
|
||
```bash | ||
go get github.com/xataio/xata-go@latest | ||
``` | ||
|
||
## Configuration | ||
|
||
The client needs a `XATA_API_KEY` environment variables for authentication and the `.xatarc` file for the database URL. Refer to [our installation guide](/docs/getting-started/installation#xatarc) to initialize your project with the `.xatarc` file. | ||
|
||
## Example | ||
|
||
After setting up your project and adding Xata credentials, create an example Go file. | ||
|
||
The following example code demonstrates using the SDK to connect to Xata, retrieve a list of workspaces, and then print out details of the first workspace in the list. | ||
|
||
In your text editor, paste the following code into your `example.go` file and save the file: | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/xataio/xata-go/xata" | ||
) | ||
|
||
func main() { | ||
workspaces, _ := xata.NewWorkspacesClient() | ||
resp, _ := workspaces.List(context.TODO()) | ||
fmt.Printf("%#v\n", *resp.Workspaces[0]) | ||
} | ||
``` | ||
|
||
In the terminal, enter `go run .` to run the code. | ||
|
||
The code snippet calls `workspaces.List(ctx)` API to list all workspaces and prints the details of the first workspace with `fmt.Printf("%#v\n", *resp.Workspaces[0])`. | ||
|
||
### Runnable Example | ||
|
||
You can run the snippet from above on your machine by, pulling the example code from the xataio/xata-go repository | ||
|
||
```bash | ||
wget -O example.go "https://raw.githubusercontent.com/xataio/xata-go/main/examples/list_workspaces.go" | ||
go mod edit -module=example.com/mod | ||
go mod download github.com/xataio/xata-go@main | ||
``` | ||
|
||
Run the code with the command: | ||
|
||
```bash | ||
XATA_API_KEY="<INSERT_YOUR_API_KEY>" go run example.go | ||
``` | ||
|
||
## Known Limitations | ||
|
||
- [Numeric operations](/docs/sdk/update#numeric-operations) are currently not supported using the update API. As a workaround, you can use the transaction API [example](/docs/sdk/transaction). | ||
- Not all Xata endpoints are available at the alpha state of the SDK. You can check the coverage [here](https://github.com/xataio/xata-go/issues/1). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.