go get -u github.com/tencentcloud/tencentcloud-sdk-go-intl-en
package mainimport ("fmt""github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common""github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/errors""github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/profile"cvm "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/cvm/v20170312")func main() {// Instantiate an authentication object. The Tencent Cloud account secretId and secretKey need to be passed in as the input parameters.credential := common.NewCredential("your-secret-id","your-secret-key",)// Instantiate a client configuration object; you can specify the timeout and other configurations.cpf := profile.NewClientProfile()cpf.HttpProfile.ReqMethod = "GET"cpf.HttpProfile.ReqTimeout = 5cpf.SignMethod = "HmacSHA1"// Instantiate the client object to request the product (with CVM as an example).client, _ := cvm.NewClient(credential, "ap-beijing", cpf)// Instantiate a request object; you can further set the request parameters according to the API called and actual conditions.request := cvm.NewDescribeZonesRequest()// Call the API you want to access through the client object; you need to pass in the request object.response, err := client.DescribeZones(request)// Handle the exceptionif _, ok := err.(*errors.TencentCloudSDKError); ok {fmt.Printf("An API error has returned: %s", err)return}// unexpected errorsif err != nil {panic(err)}// Print the returned json stringfmt.Printf("%s", response.ToJsonString())}
Feedback