Alibabacloud Sdk Client Initialization For Golang
/install alibabacloud-sdk-client-initialization-for-golang
Client Initialization Best Practices (Go)
Core Rules
- Client is goroutine-safe — safe to share across goroutines without additional synchronization.
- Use singleton pattern — do NOT create new client instances per request. Frequent client creation wastes resources.
- Prefer explicit endpoint over region-based endpoint resolution.
Recommended Client Creation
import (
"os"
"sync"
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
ecs "github.com/alibabacloud-go/ecs-20140526/v3/client"
"github.com/alibabacloud-go/tea/tea"
)
var (
ecsClient *ecs.Client
ecsClientOnce sync.Once
)
func GetEcsClient() *ecs.Client {
ecsClientOnce.Do(func() {
config := &openapi.Config{
AccessKeyId: tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")),
AccessKeySecret: tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")),
Endpoint: tea.String("ecs.cn-hangzhou.aliyuncs.com"),
}
var err error
ecsClient, err = ecs.NewClient(config)
if err != nil {
panic(err)
}
})
return ecsClient
}
Endpoint Configuration
Priority: explicit Endpoint > region-based resolution via RegionId.
// Preferred: explicit endpoint
config.Endpoint = tea.String("ecs.cn-hangzhou.aliyuncs.com")
// Alternative: SDK resolves endpoint from region
config.RegionId = tea.String("cn-hangzhou")
VPC Endpoints
Use VPC endpoints when running inside Alibaba Cloud VPC:
config.Endpoint = tea.String("ecs-vpc.cn-hangzhou.aliyuncs.com")
File Upload APIs (Advance)
Set both RegionId and Endpoint to the same region for file upload APIs:
config.RegionId = tea.String("cn-shanghai")
config.Endpoint = tea.String("objectdet.cn-shanghai.aliyuncs.com")
// VPC file upload authorization:
client.OpenPlatformEndpoint = tea.String("openplatform-vpc.cn-shanghai.aliyuncs.com")
client.EndpointType = tea.String("internal")
SDK Components
| Component | Description |
|---|---|
Core SDK (darabonba-openapi) |
Generic calls, no product dependency |
Product SDK (e.g., ecs-20140526) |
Typed client, models, convenience methods |
Debugging
Enable debug mode via environment variable to log all requests:
export DEBUG=tea
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install alibabacloud-sdk-client-initialization-for-golang - After installation, invoke the skill by name or use
/alibabacloud-sdk-client-initialization-for-golang - Provide required inputs per the skill's parameter spec and get structured output
What is Alibabacloud Sdk Client Initialization For Golang?
Initialize and manage Alibaba Cloud SDK clients in Go. Covers sync.Once singleton, goroutine safety, endpoint vs region configuration, VPC endpoints, and deb... It is an AI Agent Skill for Claude Code / OpenClaw, with 109 downloads so far.
How do I install Alibabacloud Sdk Client Initialization For Golang?
Run "/install alibabacloud-sdk-client-initialization-for-golang" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Alibabacloud Sdk Client Initialization For Golang free?
Yes, Alibabacloud Sdk Client Initialization For Golang is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Alibabacloud Sdk Client Initialization For Golang support?
Alibabacloud Sdk Client Initialization For Golang is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Alibabacloud Sdk Client Initialization For Golang?
It is built and maintained by alibabacloud-skills-team (@sdk-team); the current version is v0.0.1-beta.