最近更新时间:2023.08.29 17:08:28
首次发布时间:2023.06.09 11:16:18
本文为您介绍火山引擎Go SDK的下载地址及安装方式。
go version
可以检查当前Go的版本信息。Golang SDK下载地址:volcengine-go-sdk 。
新建一个Go项目,使用go mod作为软件依赖工具。
在go.mod中设置服务依赖。
说明
请参考Github下载地址中的release tag替换以下命令中v1.0.19为最新版本。
require github.com/volcengine/volcengine-go-sdk v1.0.19
本文以查看指定公网IP的信息为例,为您介绍如何使用Golang SDK。
创建测试文件main.go
,参考 DescribeEipAddressAttributes 的请求参数说明,添加如下代码。
// Example Code generated by Beijing Volcanoengine Technology. package vpcexample import ( "fmt" "github.com/volcengine/volcengine-go-sdk/service/vpc" "github.com/volcengine/volcengine-go-sdk/volcengine" "github.com/volcengine/volcengine-go-sdk/volcengine/credentials" "github.com/volcengine/volcengine-go-sdk/volcengine/session" ) func DescribeEipAddressAttributes() { // 设置您的ak、sk和要访问的地域 ak, sk, region := "Your AK", "Your SK", "Region" config := volcengine.NewConfig(). WithRegion(region). WithCredentials(credentials.NewStaticCredentials(ak, sk, "")) sess, err := session.NewSession(config) if err != nil { panic(err) } svc := vpc.New(sess) // 创建一个DescribeEipAddressAttributes接口 describeEipAddressAttributesInput := &vpc.DescribeEipAddressAttributesInput{ AllocationId: volcengine.String("eip-2ze7ujxscd****"), //待查看公网IP的ID } // 发起请求并处理返回或异常 resp, err := svc.DescribeEipAddressAttributes(describeEipAddressAttributesInput) if err != nil { panic(err) } fmt.Println(resp) }