To use Go to call an API through app authentication, obtain the Go SDK, create a new project, and then call the API by referring to the API calling example.
This section uses IntelliJ IDEA 2022.2.1 as an example.
Figure 1 Installing the Go plug-in

Download the SDK and demo. Then obtain the ApiGateway-go-sdk.zip package. The following table shows the files decompressed from the package.
Name | Description |
|---|---|
core\escape.go | SDK code |
core\signer.go | |
demo.go | Sample code |
In the displayed New Project dialog box, set Name to the name of the folder in the SDK package, Location to the decompression path of the folder, Language to Go, and click Create.
Figure 2 Go

Figure 3 Directory structure of the new project go

Modify the parameters in sample code demo.go as required. For details about the sample code, see API Calling Example.
import "apig-sdk/go/core"
vi ~/.bashrc
export CLOUD_SDK_AK="Obtained AK"export CLOUD_SDK_SK="Obtained SK"
source ~/.bashrc
s := core.Signer{Key: os.Getenv("CLOUD_SDK_AK"),Secret: os.Getenv("CLOUD_SDK_SK"),}
r, _ := http.NewRequest("POST", "http://c967a237-cd6c-470e-906f-a8655461897e.apigw.exampleRegion.com/api?a=1&b=2",ioutil.NopCloser(bytes.NewBuffer([]byte("foo=bar"))))
r.Header.Add("x-stage", "RELEASE")
s.Sign(r)
resp, err := http.DefaultClient.Do(r)body, err := ioutil.ReadAll(resp.Body)