golang-testing
构建更好的 Go 测试
Go 团队需要在单元测试、集成测试、mock、基准测试和覆盖率方面保持一致的测试实践。此 skill 提供实用的 Go 测试模式,Claude、Codex 和 Claude Code 可在开发过程中应用这些模式。
使用我的智能体安装
将此请求复制给你的智能体,其中包含权威 Skill 页面和清单。
Review the Skillstore skill "golang-testing" from https://skillstore.io/skills/89jobrien-golang-testing.md and its manifest at https://skillstore.io/api/skills/89jobrien-golang-testing/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.你的智能体仍应展示其计划,并按安全策略请求必要确认。
Agent 可读资源
当 AI Agent、爬虫或脚本需要干净上下文,而不是读取完整页面时,请使用这些链接。
测试它
正在使用“golang-testing”。 一个 Go 函数需要针对正常输入、空输入和无效输入进行单元测试。
预期结果:
一个表驱动测试计划,包含命名用例、预期结果、错误预期和子测试结构。
正在使用“golang-testing”。 一个服务依赖于一个 repository 和一个 email sender。
预期结果:
一个用于隔离服务的 mock 设计,并包含成功、未找到和依赖失败场景。
正在使用“golang-testing”。 一个 repository 必须针对 PostgreSQL 进行测试。
预期结果:
一个集成测试大纲,包含容器 setup、migration 步骤、清理和单独的运行命令。
安全审计
安全The static findings are false positives from Markdown code fences, Go import blocks, example identifiers, and documented Go test commands. The skill is instructional content only, with no executable installer, secret access, data exfiltration, or prompt injection evidence.
风险因素
⚡ 包含脚本 (2)
⚙️ 外部命令 (31)
分享与引用此报告
分享版本化评估报告、中性徽章、嵌入卡片和引用。Skillstore 只报告证据,不判断该 Skill 是否安全。
复制报告链接
https://skillstore.io/skills/89jobrien-golang-testing/audits/6?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown 徽章
[](https://skillstore.io/skills/89jobrien-golang-testing?utm_source=security_passport_badge)HTML 徽章
<a href="https://skillstore.io/skills/89jobrien-golang-testing?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/89jobrien-golang-testing/security.svg" alt="Skillstore security assessment" loading="lazy"></a>嵌入卡片
<iframe src="https://skillstore.io/embed/skills/89jobrien-golang-testing.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>学术引用 (APA · BibTeX · CFF)
APA 引用
Joseph OBrien. (2026). golang-testing security audit report (audit version 6) [Author version 1.0.1]. Skillstore. https://skillstore.io/skills/89jobrien-golang-testing/audits/6BibTeX 引用
@techreport{joseph-obrien-89jobrien-golang-testing-2026,
author = {Joseph OBrien},
title = {golang-testing security audit report (audit version 6)},
institution = {Skillstore},
year = {2026},
number = {6},
url = {https://skillstore.io/skills/89jobrien-golang-testing/audits/6},
note = {Author version 1.0.1}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "golang-testing security audit report (audit version 6)"
version: "1.0.1"
type: report
authors:
- name: "Joseph OBrien"
date-released: "2026-07-05"
url: "https://skillstore.io/skills/89jobrien-golang-testing/audits/6"
identifiers:
- type: other
value: "skillstore:89jobrien-golang-testing:audit:6"
description: "Skillstore immutable audit report identifier"
Skillstore 评分
评分依据 证据置信度: 高你能构建什么
编写服务测试
为 Go 服务逻辑创建表驱动单元测试和接口 mock。
验证集成流程
规划包含容器、fixtures、setup 和 teardown 步骤的集成测试。
标准化测试实践
让团队在 Go 测试结构、基准测试风格和覆盖率工作流上保持一致。
试试这些提示
Use the golang-testing skill to create a table-driven unit test for this Go function. Include success and error cases.
Use the golang-testing skill to design interface-based mocks for this service dependency. Show the test cases I should cover.
Use the golang-testing skill to plan integration tests for this Go package. Include setup, teardown, fixtures, and short-mode behavior.
Use the golang-testing skill to review this Go test suite. Identify gaps in organization, mocking, benchmarks, coverage, and reliability.
最佳实践
- 从针对纯函数和小型服务方法的表驱动测试开始。
- 将集成测试放在 build tags 或 short-mode skips 之后。
- 使用 helpers 和 fixtures 来减少 setup 噪音,同时保持可读性。
避免
- 复制示例而不根据领域行为调整断言。
- 在每次快速单元测试循环中运行缓慢的容器测试。
- 测试私有实现细节,而不是可观察的结果。
常见问题
这个 skill 会生成可运行的 Go 测试吗?
它需要第三方包吗?
它能帮助处理遗留 Go 代码吗?
它涵盖基准测试吗?
应该如何运行集成测试?
Claude Code 或 Codex 可以使用这个 skill 吗?
开发者详情
许可证
MIT
作者版本
v1.0.1
Skillstore 修订
r1
引用
c4037264bbd363c572662d6154a3ab28f5ca4f53
维护新鲜度
2026/7/22
使用量
15 次下载 · 220 次浏览
文件结构
📄 SKILL.md