Skip to content

Commit cbaa827

Browse files
author
dksimpson
committed
Edit Go client library quickstart
1 parent 3edde1b commit cbaa827

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

articles/cognitive-services/Bing-Autosuggest/includes/quickstarts/autosuggest-client-library-csharp.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ Use the Bing Autosuggest client library for .NET to get search suggestions based
1818

1919
## Prerequisites
2020

21-
* An Azure subscription. If you don't already have an Azure subscription, [create one for free](https://azure.microsoft.com/free/).
21+
* An Azure subscription. If you don't already have an Azure subscription, [you can create one for free](https://azure.microsoft.com/free/).
2222
* The current version of [.NET Core](https://dotnet.microsoft.com/download/dotnet-core).
2323

2424
[!INCLUDE [cognitive-services-bing-autosuggest-signup-requirements](~/includes/cognitive-services-bing-autosuggest-signup-requirements.md)]
2525

26-
## Create an environment variable
26+
## Create environment variables
2727

2828
>[!NOTE]
2929
> The endpoints for non-trial resources created after July 1, 2019 use the custom subdomain format shown below. For more information and a complete list of regional endpoints, see [Custom subdomain names for Cognitive Services](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-custom-subdomains).
@@ -138,7 +138,7 @@ If you're using the Visual Studio IDE, the client library is available as a down
138138
These code snippets show you how to do the following tasks with the Bing Autosuggest client library for .NET:
139139

140140
* [Authenticate the client](#authenticate-the-client)
141-
* [Send an autosuggest request](#send-an-autosuggest-request)
141+
* [Send an Autosuggest request](#send-an-autosuggest-request)
142142

143143
### Authenticate the client
144144

articles/cognitive-services/Bing-Autosuggest/includes/quickstarts/autosuggest-client-library-go.md

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: aahill
66
manager: nitinme
77
ms.service: cognitive-services
88
ms.topic: include
9-
ms.date: 04/06/2020
9+
ms.date: 05/06/2020
1010
ms.author: aahi
1111
---
1212

@@ -18,31 +18,26 @@ Use the Bing Autosuggest client library for Go to get search suggestions based o
1818

1919
## Prerequisites
2020

21-
* An Azure subscription - [create one for free](https://azure.microsoft.com/free/)
22-
* The latest version of [Go](https://golang.org/dl/)
23-
24-
## Setting up
25-
26-
### Create an Azure resource
21+
* An Azure subscription. If you don't already have an Azure subscription, [you can create one for free](https://azure.microsoft.com/free/).
22+
* The latest version of [Go](https://golang.org/dl/).
2723

2824
Begin using the Bing Autosuggest client library by creating an Azure resource. Choose the resource type below that's right for you:
2925

3026
[!INCLUDE [cognitive-services-bing-autosuggest-signup-requirements](~/includes/cognitive-services-bing-autosuggest-signup-requirements.md)]
3127

32-
### Create an environment variable
28+
## Create environment variables
3329

3430
>[!NOTE]
3531
> The endpoints for non-trial resources created after July 1, 2019 use the custom subdomain format shown below. For more information and a complete list of regional endpoints, see [Custom subdomain names for Cognitive Services](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-custom-subdomains).
3632
3733
Using your key and endpoint from the resource you created, create two environment variables for authentication:
3834
<!-- replace the below variable names with the names expected in the code sample.-->
39-
* `AUTOSUGGEST_SUBSCRIPTION_KEY` - The resource key for authenticating your requests.
40-
* `AUTOSUGGEST_ENDPOINT` - The resource endpoint for sending API requests. It will look like this:
41-
* `https://<your-custom-subdomain>.api.cognitive.microsoft.com`
35+
* `AUTOSUGGEST_SUBSCRIPTION_KEY`: The resource key for authenticating your requests.
36+
* `AUTOSUGGEST_ENDPOINT`: The resource endpoint for sending API requests. It should look like this: `https://<your-custom-subdomain>.api.cognitive.microsoft.com`
4237

4338
Use the instructions for your operating system.
4439
<!-- replace the below endpoint and key examples -->
45-
#### [Windows](#tab/windows)
40+
### [Windows](#tab/windows)
4641

4742
```console
4843
setx BING_AUTOSUGGEST_SUBSCRIPTION_KEY <replace-with-your-autosuggest-api-key>
@@ -51,7 +46,7 @@ setx BING_AUTOSUGGEST_ENDPOINT <replace-with-your-autosuggest-api-endpoint>
5146

5247
After you add the environment variable, restart the console window.
5348

54-
#### [Linux](#tab/linux)
49+
### [Linux](#tab/linux)
5550

5651
```bash
5752
export AUTOSUGGEST_SUBSCRIPTION_KEY=<replace-with-your-autosuggest-api-key>
@@ -60,7 +55,7 @@ export AUTOSUGGEST_ENDPOINT=<replace-with-your-autosuggest-api-endpoint>
6055

6156
After you add the environment variable, run `source ~/.bashrc` from your console window to make the changes effective.
6257

63-
#### [macOS](#tab/unix)
58+
### [macOS](#tab/unix)
6459

6560
Edit your `.bash_profile`, and add the environment variable:
6661

@@ -72,13 +67,13 @@ export AUTOSUGGEST_ENDPOINT=<replace-with-your-autosuggest-api-endpoint>
7267
After you add the environment variable, run `source .bash_profile` from your console window to make the changes effective.
7368
***
7469

75-
### Create a new Go project
70+
## Create a new Go project
7671

7772
In a console window (cmd, PowerShell, Terminal, Bash), create a new workspace for your Go project and navigate to it. Your workspace will contain three folders:
7873

79-
* **src** - This directory contains source code and packages. Any packages installed with the `go get` command will reside here.
80-
* **pkg** - This directory contains the compiled Go package objects. These files all have an `.a` extension.
81-
* **bin** - This directory contains the binary executable files that are created when you run `go install`.
74+
* **src**: This directory contains source code and packages. Any packages installed with the `go get` command will reside here.
75+
* **pkg**: This directory contains the compiled Go package objects. These files all have an `.a` extension.
76+
* **bin**: This directory contains the binary executable files that are created when you run `go install`.
8277

8378
> [!TIP]
8479
> Learn more about the structure of a [Go workspace](https://golang.org/doc/code.html#Workspaces). This guide includes information for setting `$GOPATH` and `$GOROOT`.
@@ -90,7 +85,7 @@ $ mkdir -p my-app/{src, bin, pkg}
9085
$ cd my-app
9186
```
9287

93-
### Install the client library for Go
88+
## Install the client library for Go
9489

9590
Now, let's install the client library for Go:
9691

@@ -104,7 +99,7 @@ or if you use dep, within your repo run:
10499
$ dep ensure -add <library-location-or-url>
105100
```
106101

107-
### Create your Go application
102+
## Create your Go application
108103

109104
Next, let's create a file named `src/sample-app.go`:
110105

@@ -113,7 +108,7 @@ $ cd src
113108
$ touch sample-app.go
114109
```
115110

116-
Open `sample-app.go` and add the package name and import the following libraries:
111+
Open `sample-app.go`, add the package name, and then import the following libraries:
117112

118113
```Go
119114
package main
@@ -128,7 +123,7 @@ import (
128123
)
129124
```
130125

131-
Create a function named `main`. Then create environment variables for your Bing Autosuggest key and endpoint.
126+
Create a function named `main`. Then, create environment variables for your Bing Autosuggest key and endpoint:
132127

133128
```go
134129
func main() {
@@ -152,7 +147,7 @@ These code samples show you how to complete basic tasks using the Bing Autosugge
152147
* [Authenticate the client](#authenticate-the-client)
153148
* [Send an API request](#send-an-api-request)
154149

155-
## Authenticate the client
150+
### Authenticate the client
156151

157152
> [!NOTE]
158153
> This quickstart assumes you've [created an environment variable](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account#configure-an-environment-variable-for-authentication) for your Bing autosuggest key, named `BING_AUTOSUGGEST_SUBSCRIPTION_KEY`, and one for your endpoint named `BING_AUTOSUGGEST_ENDPOINT`.
@@ -169,9 +164,9 @@ client.Authorizer = autorest.NewCognitiveServicesAuthorizer(subscription_key)
169164
client.Endpoint = endpoint
170165
```
171166

172-
## Send an API request
167+
### Send an API request
173168

174-
In the same method, use the client's [AutoSuggestMethodAsync](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.autosuggestclientextensions.autosuggestmethodasync?view=azure-dotnet#Microsoft_Azure_CognitiveServices_Search_AutoSuggest_AutoSuggestClientExtensions_AutoSuggestMethodAsync_Microsoft_Azure_CognitiveServices_Search_AutoSuggest_IAutoSuggestClient_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_Collections_Generic_IList_System_String__System_Threading_CancellationToken_) method to send a query to Bing. Then iterate over the [Suggestions](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.models.suggestions?view=azure-dotnet) response, and print the first suggestion.
169+
In the same method, use the client's [AutoSuggestMethodAsync](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.autosuggestclientextensions.autosuggestmethodasync?view=azure-dotnet#Microsoft_Azure_CognitiveServices_Search_AutoSuggest_AutoSuggestClientExtensions_AutoSuggestMethodAsync_Microsoft_Azure_CognitiveServices_Search_AutoSuggest_IAutoSuggestClient_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_Collections_Generic_IList_System_String__System_Threading_CancellationToken_) method to send a query to Bing. Then, iterate over the [Suggestions](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.models.suggestions?view=azure-dotnet) response, and print the first suggestion.
175170

176171
```Go
177172
// This should return the query suggestion "xbox."
@@ -209,8 +204,8 @@ go run sample-app.go
209204

210205
If you want to clean up and remove a Cognitive Services subscription, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it.
211206

212-
* [Portal](../../../cognitive-services-apis-create-account.md#clean-up-resources)
213-
* [Azure CLI](../../../cognitive-services-apis-create-account-cli.md#clean-up-resources)
207+
* [Delete a resource group in the Azure portal](../../../cognitive-services-apis-create-account.md#clean-up-resources).
208+
* [Delete a resource group in the Azure CLI](../../../cognitive-services-apis-create-account-cli.md#clean-up-resources).
214209

215210
## Next steps
216211

0 commit comments

Comments
 (0)