Examples of using OpenSearch SDK for Go

更新时间:
复制 MD 格式

Describes how to add the required dependencies and import the Go client for the OpenSearch SDK for Go.

Import dependencies

Add the following dependencies to your go.mod file:

module main

go 1.16

require (
 github.com/alibabacloud-go/opensearch-util v1.0.1 // indirect
 github.com/alibabacloud-go/tea v1.1.15
 github.com/alibabacloud-go/tea-utils v1.3.9
 github.com/aliyun/credentials-go v1.1.0 // indirect
)

Import the Go client

OpenSearch routes requests through a proprietary gateway that requires a custom signature algorithm. To handle request signing, import the Go client into your project. For the Go client source code, see Go client. Save the code as client.go, and place the file in your project.

Place go.mod and client.go in the following directories:

Directory of go.mod: src/go.mod
Directory of client.go: src/client/client.go