← 返回 Skills 市场
sdk-team

Alibabacloud Sdk Client Initialization For Golang

作者 alibabacloud-skills-team · GitHub ↗ · v0.0.1-beta · MIT-0
cross-platform ⚠ suspicious
109
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install 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...
使用说明 (SKILL.md)

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
安全使用建议
This skill appears to do what it says (Go best practices for Alibaba Cloud clients) but it uses sensitive environment variables in its examples while the manifest declares none. Before installing or using it: (1) Confirm where and how your ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET will be provided and stored; prefer instance/RAM roles or short-lived STS tokens over long-lived keys. (2) Avoid enabling DEBUG=tea in production—it can log request contents and headers with secrets. (3) If you plan to allow the agent to run these instructions, ensure the agent process/enclave cannot exfiltrate environment variables to untrusted endpoints. (4) Ask the skill author to declare required env vars (and primary credential) in the manifest or to show vetted code; treat the current omission as a red flag. If you need higher assurance, request the actual source code or a signed, published reference rather than instruction-only content.
功能分析
Type: OpenClaw Skill Name: alibabacloud-sdk-client-initialization-for-golang Version: 0.0.1-beta The skill bundle provides legitimate documentation and Go code examples for initializing Alibaba Cloud SDK clients. It follows industry best practices by using environment variables for credentials and implementing the singleton pattern with sync.Once. No malicious code, data exfiltration, or prompt injection attempts were found in SKILL.md or _meta.json.
能力评估
Purpose & Capability
Name/description and the SKILL.md are consistent: the document provides Go examples and best practices for initializing Alibaba Cloud SDK clients (singleton pattern, endpoints, VPC endpoints, debug). However the runtime instructions rely on environment credentials (ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET) even though the skill metadata lists no required env or primary credential, which is an omission/incoherence.
Instruction Scope
The SKILL.md contains concrete code that calls os.Getenv(...) for sensitive credentials and suggests setting DEBUG=tea to log all requests. The manifest did not declare those environment requirements. The instructions also recommend panicking on client construction errors (which may crash a process) and enabling debug logging that could expose sensitive headers/payloads — these behaviors expand the security surface beyond what the manifest communicates.
Install Mechanism
This is an instruction-only skill with no install spec and no code files to be written or executed by an installer, which is the lowest-risk install mechanism.
Credentials
Although asking for Alibaba Cloud credentials is reasonable for an SDK client, the skill manifest declares no required environment variables or primary credential while the code examples explicitly read ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET (and references DEBUG). This mismatch (undeclared sensitive env access) is disproportionate and should be fixed or justified.
Persistence & Privilege
The skill does not request always:true, does not modify other skills or system-wide settings, and is instruction-only. It does not request persistent presence or elevated agent privileges.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install alibabacloud-sdk-client-initialization-for-golang
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /alibabacloud-sdk-client-initialization-for-golang 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.0.1-beta
- Initial beta release. - Provides best practices for initializing and managing Alibaba Cloud SDK clients in Go. - Documents goroutine-safe client usage and recommends the singleton pattern with `sync.Once`. - Explains endpoint and region configuration, including VPC and file upload scenarios. - Includes sample code for safe client initialization. - Details debug instructions and key SDK components.
元数据
Slug alibabacloud-sdk-client-initialization-for-golang
版本 0.0.1-beta
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

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... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 109 次。

如何安装 Alibabacloud Sdk Client Initialization For Golang?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install alibabacloud-sdk-client-initialization-for-golang」即可一键安装,无需额外配置。

Alibabacloud Sdk Client Initialization For Golang 是免费的吗?

是的,Alibabacloud Sdk Client Initialization For Golang 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Alibabacloud Sdk Client Initialization For Golang 支持哪些平台?

Alibabacloud Sdk Client Initialization For Golang 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Alibabacloud Sdk Client Initialization For Golang?

由 alibabacloud-skills-team(@sdk-team)开发并维护,当前版本 v0.0.1-beta。

💬 留言讨论