cgo-bindings

将 Go 链接到 C 或 Rust 静态库的 cgo 规范:import "C" 指令、类型/字符串转换、CString 内存管理、线程安全以及 Go 指针固定。在生成或审查调用 C 或 Rust 核心的 cgo 绑定时加载。

仓库最近推送
GitHub Stars
182
Forks
19
Issues / PRs
2

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "cgo-bindings":https://skillpi.com/zh/skills/deepskill-ed66701cd29c2ef871b1cd62f72f500a0f1fb3bac1e2c847e39e211ecce307b2。安装前核对上游来源和版本:https://github.com/Goldziher/ai-rulez。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

将 Go 链接到 C 或 Rust 静态库的 cgo 规范:import "C" 指令、类型/字符串转换、CString 内存管理、线程安全以及 Go 指针固定。在生成或审查调用 C 或 Rust 核心的 cgo 绑定时加载。

0 下载

介绍来源: third_party · Goldziher · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: cgo-bindings
description: "cgo conventions for linking Go to a C or Rust static library: import \"C\" directives, type/string conversion, CString memory management, thread safety, and Go pointer pinning. Load when generating or reviewing cgo bindings that call a C or Rust core from Go."
  • Use import "C" with // #cgo LDFLAGS: and // #cgo CFLAGS: directives for linking.
  • Declare C header functions in comment block immediately above import "C" — no blank line between.
  • Type mapping: C.int, C.long, C.char. Use C.CString() and C.GoString() for string conversion.
  • Memory: C.CString() allocates — always defer C.free(unsafe.Pointer(cStr)) immediately after creation.
  • Error handling: return error codes from C functions, convert to Go error values. Check all return values.
  • Link Rust static libraries: // #cgo LDFLAGS: -L./target/release -lmylib. Build Rust with crate-type = ["staticlib"].
  • Thread safety: C functions called from Go may run on any OS thread. Use runtime.LockOSThread() when needed.
  • Go pointer passing: use runtime.Pinner (Go 1.21+) to pin Go memory passed to C. Never pass Go pointers without pinning.
  • Test with go test (requires CGO_ENABLED=1). Mock C layer for unit tests, use integration tests for real FFI.
  • Build: CGO_ENABLED=1 go build. Cross-compilation requires appropriate C toolchain.
  • Anti-patterns: leaking C.CString memory, passing unpinned Go pointers to C, ignoring C return codes.

版本历史

  1. v5.15.0 GitHub ↗
    原版更新说明

    ## What's Changed * chore(deps): bump github.com/parquet-go/parquet-go from 0.32.0 to 0.32.1 in /tools/skillbench by @dependabot[bot] in https://github.com/Goldziher/ai-rulez/pull/597 * chore(deps): bump @astrojs/starlight from 0.42.11 to 0.43.1 in /website by @dependabot[bot] in https://github.com/Goldziher/ai-rulez/pull/595 * feat(plugin): configurable Cursor hook root fallback by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/600 * chore: refresh dependencies, harness names and fix AR005 flag-value false positive by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/601 * chore(release): prepare ai-rulez 5.15.0 by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/602 **Full Changelog**: https://github.com/Goldziher/ai-rulez/compare/v5.14.1...v5.15.0

  2. v5.14.1 GitHub ↗
    原版更新说明

    ## What's Changed * fix(config): honor XDG_CACHE_HOME for the user cache by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/592 **Full Changelog**: https://github.com/Goldziher/ai-rulez/compare/v5.14.0...v5.14.1

  3. v5.14.0 GitHub ↗
    原版更新说明

    ## What's Changed * chore(deps): bump @astrojs/starlight from 0.42.10 to 0.42.11 in /website by @dependabot[bot] in https://github.com/Goldziher/ai-rulez/pull/576 * fix(harnessnames): refresh copilot and cortex built-ins from their sources by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/583 * fix(config): make the session-start briefing source-aware by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/584 * feat(mcp): expose worktree_setup for agent-created worktrees by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/587 * docs(publish): add a verify-before-install recipe for consumers by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/585 * chore(release): prepare ai-rulez 5.14.0 by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/588 **Full Changelog**: https://github.com/Goldziher/ai-rulez/compare/v5.13.4...v5.14.0

  4. v5.13.4 GitHub ↗
    原版更新说明

    ## What's Changed * test(bench): measure native and MCP skill discovery by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/575 * fix(npm): stop the Windows CLI tree when the wrapper exits by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/574 * fix(mcp): improve Claude skill discovery for v5.13.4 by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/577 **Full Changelog**: https://github.com/Goldziher/ai-rulez/compare/v5.13.3...v5.13.4

  5. v5.13.3 GitHub ↗
    原版更新说明

    ## What's Changed * ci: keep generated release artifacts out of Git by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/567 * docs: clarify native and MCP skill discovery by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/568 * fix(npm): preserve stdout and forward termination by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/566 * fix(pathglob): preserve Unicode literals by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/569 * fix(semver): validate release age before duration conversion by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/570 * fix(agents): preserve adjacent AGENTS.md sections by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/571 * bench: add paired skill discovery fixture and protocol by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/572 * chore(release): prepare ai-rulez 5.13.3 by @Goldziher in https://github.com/Goldziher/ai-rulez/pull/573 **Full Changelog**: https://github.com/Goldziher/ai-rulez/compare/v5.13.2...v5.13.3

此处仅展示最近 5 个版本。 在原站查看完整版本历史 ↗

当前收录版本

0.0.1

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值78/100

亮点

  • 提供 Go 调用 C/Rust 静态库的完整 cgo 规范,实用性强
  • 覆盖内存管理、线程安全、指针固定等关键 FFI 场景
触发精准92/100

亮点

  • 触发词精准完整,覆盖多种变体,边界清晰
结构规范68/100

待提升项

  • 缺少端到端示例 原报告严重程度:轻微

    内容以 bullet points 形式组织,缺少完整的端到端示例

    改进建议:建议补充一个完整的 cgo 绑定示例,展示从 Go 调用 C 函数的完整流程

  • 缺少明确的步骤划分 原报告严重程度:轻微

    内容未按 Phase/步骤划分,执行流程不够清晰

    改进建议:建议将内容划分为准备、绑定、调用、测试等阶段,提升可读性

亮点

  • frontmatter 完整,内容组织清晰
执行可靠85/100

亮点

  • 工具来源明确,参数正确,覆盖主要异常场景
  • 提供了内存管理、线程安全、指针固定等关键实践
证据可验 (前四项均值)81/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。