Skip to content

Commit

Permalink
chore(go): update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fluf22 committed Oct 30, 2023
1 parent 42226ca commit 4f8ccfa
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 8 deletions.
16 changes: 9 additions & 7 deletions website/docs/clients/guides/customized-client-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ val client = SearchClient(
)
)
```
<TabItem value="go">

```go
// TBD
```

</TabItem>

<TabItem value="dart">
Expand All @@ -70,7 +64,15 @@ var client = SearchClient(
</TabItem>

<TabItem value="go">
// TBD
If you enable the `debug` property of the Go API client, it will print the request and response to the standard output.

```go
searchClient := search.NewClientWithConfig(search.Configuration{
AppID: "<YOUR_APP_ID>",
ApiKey: "<YOUR_API_KEY>",
Debug: true,
})
```
</TabItem>
</TabsLanguage>

Expand Down
68 changes: 67 additions & 1 deletion website/docs/clients/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,73 @@ void main() async {
</TabItem>

<TabItem value="go">
// TBD

```go
package main

import (
"fmt"

"github.com/algolia/algoliasearch-client-go/v4/algolia/search"
)

func main() {
// Instantiate the client
searchClient := search.NewClient("<YOUR_APP_ID>", "<YOUR_API_KEY>")

// Add a new record to your Algolia index.
response, err := searchClient.AddOrUpdateObject(
searchClient.NewApiAddOrUpdateObjectRequest(
"<YOUR_INDEX_NAME>",
"1",
map[string]interface{}{
"name": "Foo",
"age": 42,
"city": "Paris",
},
),
)
if err != nil {
panic(err)
}

// Wait for the save operation to complete.
_, err = searchClient.WaitForTask(
indexName,
*response.TaskID,
nil,
nil,
nil,
)
if err != nil {
panic(err)
}

// Fetch search results.
searchResponse, err := searchClient.Search(
searchClient.NewApiSearchRequest(
search.NewSearchMethodParams(
[]search.SearchQuery{
search.SearchForHitsAsSearchQuery(
search.NewSearchForHits(
indexName,
search.WithSearchForHitsQuery("<YOUR_SEARCH_QUERY>"), // Typo tolerant search.
),
),
},
),
),
)
if err != nil {
panic(err)
}

for _, result := range searchResponse.Results {
fmt.Printf("Result: %v", result.SearchResponse)
}
}
```

</TabItem>

</TabsLanguage>
Expand Down

0 comments on commit 4f8ccfa

Please sign in to comment.