You need to enable JavaScript to run this app.
文档中心
视频点播

视频点播

复制全文
下载 pdf
Go SDK
工具服务
复制全文
下载 pdf
工具服务

本文为您提供了服务端 Go SDK 的工具服务模块的接口调用示例。

前提条件

调用接口前,请先完成集成 Go SDK。

调用示例

获取 IP 归属信息

接口请求参数和返回参数详见 OpenAPI:获取 IP 归属信息。
将 <YOUR_IP_LIST> 替换为待查询的实际 IP 地址;多个地址用英文逗号或换行符分隔,最多 50 个。例如 1.1.1.1,8.8.8.8。
将示例保存为 describe_ip_info_test.go,放入已集成 SDK 的 Go 模块目录,配置凭证后在该目录执行 go test -run Test_DescribeIpInfo -v。文件的包名须与所在目录一致。

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_DescribeIpInfo(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodDescribeIPInfoRequest{
                Ips: "<YOUR_IP_LIST>",
        }

        resp, status, err := instance.DescribeIpInfo(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}
最近更新时间:2026.10.21 13:17:49
这个页面对您有帮助吗?
有用
有用
无用
无用