golang-structs-interfaces
Design Better Go Structs and Interfaces
Poor type boundaries make Go code harder to test, extend, and review. This skill applies focused interfaces, useful structs, safe assertions, and clear composition patterns.
Install with my Agent
Copy this request to your Agent. It includes the canonical Skill page and manifest.
Review the Skillstore skill "golang-structs-interfaces" from https://skillstore.io/skills/samber-golang-structs-interfaces.md and its manifest at https://skillstore.io/api/skills/samber-golang-structs-interfaces/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.Your Agent should still show its plan and request any confirmation required by the security policy.
Agent-readable resources
Use these links when an AI agent, crawler, or script needs clean context instead of reading the full page.
Test it
Using "golang-structs-interfaces". A service constructor accepts a storage dependency and currently returns an interface.
Expected outcome:
Return the concrete service pointer and accept the consumer-owned storage interface. Callers retain access to the service API while tests can provide a small mock.
Using "golang-structs-interfaces". A server embeds a data store but should expose only its HTTP behavior.
Expected outcome:
Embed the HTTP handler when its methods should be promoted. Keep the data store as a named field so its internal methods remain private to the server implementation.
Using "golang-structs-interfaces". A registry panics when used as its zero value.
Expected outcome:
Initialize the internal map lazily in the mutating method. The zero value can then be declared directly and used without a constructor.
Security Audit
SafeAll 77 static findings are false positives caused by Go raw-string syntax, struct tags, explanatory prose, evaluation text, or documentation URLs. The reviewed skill contains no evidence of runtime command execution, network access, system reconnaissance, data exfiltration, or prompt injection.
Risk Factors
โ๏ธ External commands (50)
๐ Network access (2)
Share & cite this report
Share the versioned assessment report, neutral badge, embed card, and citations. Skillstore reports evidence without deciding whether this Skill is safe.
Copy report link
https://skillstore.io/skills/samber-golang-structs-interfaces/audits/1?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown badge
[](https://skillstore.io/skills/samber-golang-structs-interfaces?utm_source=security_passport_badge)HTML badge
<a href="https://skillstore.io/skills/samber-golang-structs-interfaces?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/samber-golang-structs-interfaces/security.svg" alt="Skillstore security assessment" loading="lazy"></a>Embed card
<iframe src="https://skillstore.io/embed/skills/samber-golang-structs-interfaces.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>Academic citations (APA ยท BibTeX ยท CFF)
APA citation
samber. (2026). golang-structs-interfaces security audit report (audit version 1) [Author version 1.2.1]. Skillstore. https://skillstore.io/skills/samber-golang-structs-interfaces/audits/1BibTeX citation
@techreport{samber-samber-golang-structs-interfaces-2026,
author = {samber},
title = {golang-structs-interfaces security audit report (audit version 1)},
institution = {Skillstore},
year = {2026},
number = {1},
url = {https://skillstore.io/skills/samber-golang-structs-interfaces/audits/1},
note = {Author version 1.2.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-structs-interfaces security audit report (audit version 1)"
version: "1.2.1"
type: report
authors:
- name: "samber"
date-released: "2026-09-23"
url: "https://skillstore.io/skills/samber-golang-structs-interfaces/audits/1"
identifiers:
- type: other
value: "skillstore:samber-golang-structs-interfaces:audit:1"
description: "Skillstore immutable audit report identifier"
Skillstore Score
Why this score Evidence Confidence: MediumWhat You Can Build
Shape a New Go Package
Define focused interfaces, concrete constructors, and composable structs for a new package.
Review Existing Type Boundaries
Find oversized interfaces, premature abstractions, unsafe assertions, and inconsistent receivers.
Improve Testability Safely
Introduce consumer-owned interfaces and dependency injection where tests or multiple implementations justify them.
Try These Prompts
I have a Go package with one concrete dependency. Explain whether I need an interface, where it should live, and why.
Review this Go struct design and recommend embedding or a named field for each dependency. Explain which methods should be exposed.
Review these Go type assertions and type switches. Replace panic-prone assertions, handle nil values, and preserve optional behavior.
Audit this Go package for interface size, constructor return types, receiver consistency, struct tags, copy safety, and compile-time interface checks. Give prioritized changes with reasoning.
Best Practices
- Define the smallest interface at the point where the behavior is consumed.
- Prefer concrete returns, safe comma-ok assertions, and useful zero values.
- Run go vet, race tests, and focused round-trip tests after changing type design.
Avoid
- Do not create interfaces only for hypothetical flexibility.
- Do not return interfaces from constructors when callers need the concrete API.
- Do not mix receiver styles or use unchecked assertions for recoverable input.
Frequently Asked Questions
Where should a Go interface be defined?
Should constructors return interfaces?
When should I add an interface?
When should I embed a type?
Why use the comma-ok assertion form?
Should a Go receiver use a pointer or value?
Developer Details
Author
samberLicense
MIT
Author version
v1.2.1
Skillstore revision
r1
Ref
2aa351cb09c29b7287d263bd8ea81e9bee3b2a61
Maintenance freshness
9/30/2026
Usage
0 downloads ยท 0 views
File structure
๐ evals/
๐ evals.json
๐ references/
๐ struct-fields.md
๐ type-assertions.md
๐ SKILL.md