gstruct

Gomega matchers for checking parts of nested Go structs, lists, maps, and pointers without comparing every detail.

In plain words
What is it for?
Use them to verify complex response data or other nested Go values while ignoring approved differences.
Why use it?
They make tests easier to write when only selected fields, elements, or keys matter in a large value.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/onsi/gomega/gstruct
Any agent
npx skills add onsi/gomega --skill gstruct
Clone the repo
git clone --depth 1 https://github.com/onsi/gomega

Made for: Claude Code, Codex.

Per session 104 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,796 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00104 $0.01796
Opus 5 $0.00052 $0.00898
Sonnet 5 $0.00021 $0.00359
Haiku 4.5 $0.00010 $0.00180

Measured 3d ago against content hash 76aa134f8cd7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

gstruct scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/gomega/skills/gstruct/SKILL.md · 158 lines

How it starts

The opening of the file, as written. The whole thing — 158 lines — stays where its author put it; the contents beside it link to each section on GitHub.

gstruct: matching complex data types

gstruct builds composite matchers that apply a separate matcher to each field of a struct, each element of a slice, each key of a map, or the target of a pointer. It is the tool for fuzzy-matching large, deeply nested values. Docs: https://onsi.github.io/gomega/#gstruct-testing-complex-data-types.

Dot-import gomega; import gstruct normally (or dot-import it too):

import (
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gstruct"
)

The values in Fields/Elements/Keys are themselves matchers. That is the whole point: compose with the core catalog (gomega:matchers) and combinators like And/Or/Not/WithTransform (gomega:composing-matchers). Examples below assume gstruct is dot-imported for brevity.

If you find yourself building an overly complex gstruct matcher, consider if you should be building a custom matcher (gomega:custom-matchers) instead.

Structs — Fields

Fields is map[string]types.GomegaMatcher keyed by field name.

actual := struct {
	A int
	B bool
	C string
}{5, true, "foo"}

Expect(actual).To(MatchAllFields(Fields{
	"A": BeNumerically("<", 10),
	"B": BeTrue(),
	"C": Equal("foo"),
}))

MatchAllFields requires an exact 1:1 mapping — every field must have a matcher and every matcher must map to a field. This is great for maintainability: adding or removing a struct field breaks the test until you update it.

To match a subset/superset, use MatchFields(options, Fields{...}):

// IgnoreExtras: ignore struct fields with no matcher
Expect(actual).To(MatchFields(IgnoreExtras, Fields{
	"A": BeNumerically("<", 10),
	"B": BeTrue(), // no entry for C — fine
}))

// IgnoreMissing: ignore matchers with no corresponding field
Expect(actual).To(MatchFields(IgnoreMissing, Fields{
	"A": BeNumerically("<", 10),
	"B": BeTrue(),
	"C": Equal("foo"),
	"D": Equal("bar"), // ignored — actual has no field D
}))

IgnoreUnexportedExtras is a middle ground: it ignores only unexported extra fields (gstruct can't read them via reflect anyway) while still requiring all exported fields to be matched.

Read the full file on GitHub · 158 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 158 lines · 104 tokens per session scan A 76aa134f8cd7

Subscribe to this mod's changes

gstruct is a skill published in the GitHub repository onsi/gomega (2,355 stars, last pushed 6d ago), licensed MIT. It adds 104 tokens to every session and 1,796 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

gen-test

Generate idiomatic tests for Go packages and handlers in the Meshery project.

meshery/meshery · 18 tokens

setup

Wire Ginkgo into a Go package — install the ginkgo CLI and Ginkgo+Gomega, ginkgo bootstrap to generate the suitetest.go (TestXxx/RegisterFailHandler(Fail)/RunSpecs), the package xxxtest convention, dot-import alternatives (aliased import, dsl/ subpackages, --nodot), ginkgo generate, and testing.T interop via…

onsi/ginkgo · 118 tokens

golang-testing

Production-ready Golang tests — table-driven tests, testify suites and mocks, parallel tests, fuzzing, fixtures, goroutine leak detection with goleak, snapshot testing, code coverage, integration tests, idiomatic test naming. Use when writing or reviewing Go tests, choosing a testing approach, setting up Go test CI…

samber/cc-skills-golang · 115 tokens

golang-stretchr-testify

Comprehensive guide to stretchr/testify for Golang testing. Covers assert, require, mock, and suite packages in depth. Use when writing tests with testify, creating mocks, setting up test suites, or choosing between assert and require. Covers testify assertions, mock expectations, argument matchers, call verification…

samber/cc-skills-golang · 97 tokens

go-testing

Trigger: Go tests, go test coverage, Bubbletea teatest, golden files. Apply focused Go testing patterns.

Gentleman-Programming/gentle-ai · 26 tokens

add-go-test

Write or extend Go unit tests in this repo. Use when the user asks to add or update Go tests.

authgear/authgear-server · 26 tokens