获取SDK

go get -u github.com/aliyun/alibaba-cloud-sdk-go/sdk

创建客户端

package main

import "github.com/aliyun/alibaba-cloud-sdk-go/sdk"

func main() {

	client, err := sdk.NewClientWithAccessKey("REGION_ID", "ACCESS_KEY_ID", "ACCESS_KEY_SECRET")
	if err != nil {
		// Handle exceptions
		panic(err)
	}
}

发起请求

package main

import "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"

func main() {
	request := requests.NewCommonRequest()                // 构造一个公共请求
	request.Method = "POST"                               // 设置请求方式
	request.Product = "nlp-automl"                               // 指定产品
	request.Domain = "nlp-automl.cn-hangzhou.aliyuncs.com"                   // 指定域名则不会寻址,如认证方式为 Bearer Token 的服务则需要指定
	request.Version = "2019-11-11"                        // 指定产品版本
	request.ApiName = "GetPredictResult"                    // 指定接口名
	request.QueryParams["ModelId"] = 1818  // 设置参数值
	request.QueryParams["Content"] = "中华人民共和国解放军"         // 设置参数值
	request.TransToAcsRequest()                           // 把公共请求转化为acs请求
}