go-bindings-patterns
Instructions for go bindings patterns.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
priority: high
Go Bindings Patterns
Role: Go bindings for Rust core. Work on CGO bridge and Go SDK/E2E suite.
Scope: Go 1.25 module, CGO wrappers around C FFI, Go-idiomatic config/result structs, linting setup, benchmark harness scripts.
Commands: cd packages/go/v4 && go test ./..., golangci-lint run ./..., ensure LD_LIBRARY_PATH/DYLD_LIBRARY_PATH includes target/release when running tests.
FFI: Binding header (packages/go/v4/binding.go) must stay in sync with C FFI header. Add new APIs to Rust first, then expose through CGO, update types.go, regenerate Go E2E tests when fixtures change.
Critical: Core logic lives in Rust. Go code should remain thin wrappers/helper utilities over C API. Coordinate with Rust team for shared logic.
Go 1.25+ Standards
- Go 1.25+; error wrapping with fmt.Errorf("%w", err), errors.Is/As for checking
- Testing: *_test.go with _test package suffix (black-box), table-driven with t.Run()
- golangci-lint: errcheck, govet, staticcheck, gosec, gocyclo (complexity <=25)
- Coverage 80%+ on business logic; go test -race for concurrency bugs
- Package structure: cmd/, internal/ (no cross-service imports), pkg/ for libraries
- Naming: PascalCase (types), camelCase (vars), SCREAMING_SNAKE_CASE (consts)
- Context.Context first param in I/O funcs; respect cancellation with select <-ctx.Done()
- Structured logging: zerolog with Str/Int/Err chaining
- Never: bare error returns, cross-service internal imports, panic in libraries
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-03-11
- 索引更新时间
- 2026-03-11
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!