All Products
Search
Document Center

OpenSearch:Examples of using OpenSearch SDK for Go

Last Updated:Apr 08, 2025

This topic describes how to import dependencies and the Go client.

Import dependencies

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 uses an in-house gateway service. You can use a signature algorithm only after you import the Go client. For more information about the sample code, see Go client. Save the code to a file named client.go, and then import the file to your project.

Import dependencies and the Go client to the following directories in your project:

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