go mod
is used). Plus, the necessary environment variables such as GOPATH
should be set properly.tms.tencentcloudapi.com
) or a specified region (at tms.ap-guangzhou.tencentcloudapi.com
for Guangzhou, for example).System Platform | Command |
Linux / macOS | export GOPROXY=https://mirrors.tencent.com/go/ |
Windows | set GOPROXY=https://mirrors.tencent.com/go/ |
GO111MODULE
should be auto
or on
, and go mod init xxx
should be executed in your project . If you use GOPATH
, see the full installation method.GOPATH
and Go Modules
.Installation Method | Description | Command |
On-demand installation (recommended) | Install the common basic package | go get -v -u github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common |
| Install the corresponding service package (such as CVM) | go get -v -u github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm |
Full installation | Download the packages of all Tencent Cloud services at once | go get -v -u github.com/tencentcloud/tencentcloud-sdk-go |
go mod
, the SDK version number has been reduced from v3.x to v1.x, and all tags of v3.0.*
and 3.0.*
were removed on May 10, 2021. If you need to backtrack previous tags, refer to the commit2tag
file in the root directory of the project.$GOPATH/src/github.com/tencentcloud
directory.TextModeration
API. The region
is configured as Guangzhou
as an example and should be configured as needed.package mainimport ("fmt""github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common""github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors""github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"tms "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tms/v20201229") func main() {credential: = common.NewCredential("SecretId", "SecretKey", ) cpf: = profile.NewClientProfile() cpf.HttpProfile.Endpoint = "tms.tencentcloudapi.com"client,_: = tms.NewClient(credential, "ap-guangzhou", cpf) request: = tms.NewTextModerationRequest() response,err: = client.TextModeration(request) if _,ok: = err.( * errors.TencentCloudSDKError);ok {fmt.Printf("An API error has returned: %s", err) return}if err != nil {panic(err)}fmt.Printf("%s", response.ToJsonString())}
Was this page helpful?