go-bindings-patterns

Develop Go bindings for Rust cores via CGO with SDK standards.

836|66|Updated Feb 3, 2025
One-click install
npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill go-bindings-patterns-kreuzberg-dev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-bindings-patterns
Source: https://github.com/kreuzberg-dev/html-to-markdown/tree/main/.codex/skills/go-bindings-patterns
Command: npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill go-bindings-patterns-kreuzberg-dev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides guidance and patterns for creating Go bindings that interface with a Rust core, ensuring efficient and idiomatic Go development for cross-language projects.

Core Features & Use Cases

  • CGO Bridge Management: Details on maintaining synchronization between Go and C FFI headers.
  • Go SDK Development: Standards for building Go-idiomatic configuration, result structures, and end-to-end testing suites.
  • Use Case: Developers working on a project with a Rust backend can use this Skill to understand how to effectively build and maintain the Go client libraries that interact with the Rust core via CGO.

Quick Start

Follow the go bindings patterns to update the Go E2E tests when fixtures change.

Frequently Asked Questions about go-bindings-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create Go bindings for a Rust core using CGO?

To create Go bindings for a Rust core, you write thin CGO wrappers that interface with C APIs exposed by Rust. This approach provides patterns for maintaining FFI synchronization and structuring Go code to act as an idiomatic SDK over the Rust backend.

What are common CGO wrapper maintenance patterns for Go and Rust FFI?

CGO wrapper maintenance involves keeping Go and C FFI headers synchronized. You ensure the thin Go wrappers correctly map to the underlying C APIs exposed by the Rust core, preventing memory leaks and handling cross-language data structures safely.

Does this approach support building a Go SDK over Rust for Go 1.25+?

Yes, the patterns are designed for Go 1.25+ modules. They provide standards for building idiomatic Go SDK configuration, result structures, and end-to-end testing suites that interact with a Rust core via CGO.

How do I benchmark Go bindings that interface with a Rust core?

You benchmark Go bindings by applying the provided benchmarking patterns for Go 1.25+ modules. This allows you to measure the overhead of the CGO FFI calls and ensure the thin wrappers perform efficiently when interacting with the Rust core.

Why do my Go and C FFI headers go out of sync when updating Rust core bindings?

FFI headers go out of sync when Rust core updates are not reflected in the CGO bridge. Addressing critical FFI synchronization aspects ensures the Go wrapper structures match the C APIs, preventing runtime errors and maintaining SDK stability.

What is the best way to structure Go SDK result structures for Rust FFI?

The best way to structure Go SDK result structures is to follow Go-idiomatic configuration standards provided by the binding patterns. This ensures the thin wrappers cleanly translate C API outputs from the Rust core into native Go types for end-to-end testing.