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.
๋ด ์์ด์ ํธ๋ก ์ค์น
์ด ์์ฒญ์ ์์ด์ ํธ์ ๋ณต์ฌํ์ธ์. ๊ณต์ Skill ํ์ด์ง์ ๋งค๋ํ์คํธ๊ฐ ํฌํจ๋์ด ์์ต๋๋ค.
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.์์ด์ ํธ๋ ๊ณ์ํด์ ๊ณํ์ ํ์ํ๊ณ ๋ณด์ ์ ์ฑ ์์ ์๊ตฌํ๋ ํ์ธ์ ์์ฒญํด์ผ ํฉ๋๋ค.
์์ด์ ํธ๊ฐ ์ฝ๊ธฐ ์ฌ์ด ๋ฆฌ์์ค
AI ์์ด์ ํธ, ํฌ๋กค๋ฌ, ์คํฌ๋ฆฝํธ๊ฐ ์ ์ฒด ํ์ด์ง ๋์ ์ ๋ฆฌ๋ ์ปจํ ์คํธ๋ง ํ์ํ ๋ ์ด ๋งํฌ๋ฅผ ์ฌ์ฉํ์ธ์.
ํ ์คํธํด ๋ณด๊ธฐ
"golang-structs-interfaces" ์ฌ์ฉ ์ค์ ๋๋ค. A service constructor accepts a storage dependency and currently returns an interface.
์์ ๊ฒฐ๊ณผ:
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.
"golang-structs-interfaces" ์ฌ์ฉ ์ค์ ๋๋ค. A server embeds a data store but should expose only its HTTP behavior.
์์ ๊ฒฐ๊ณผ:
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.
"golang-structs-interfaces" ์ฌ์ฉ ์ค์ ๋๋ค. A registry panics when used as its zero value.
์์ ๊ฒฐ๊ณผ:
Initialize the internal map lazily in the mutating method. The zero value can then be declared directly and used without a constructor.
๋ณด์ ๊ฐ์ฌ
์์ All 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.
์ํ ์์ธ
โ๏ธ ์ธ๋ถ ๋ช ๋ น์ด (50)
๐ ๋คํธ์ํฌ ์ ๊ทผ (2)
์ด ๋ณด๊ณ ์ ๊ณต์ ๋ฐ ์ธ์ฉ
๋ฒ์ ์ด ์ง์ ๋ ํ๊ฐ ๋ณด๊ณ ์, ์ค๋ฆฝ ๋ฐฐ์ง, ์๋ฒ ๋ ์นด๋ ๋ฐ ์ธ์ฉ์ ๊ณต์ ํ์ธ์. Skillstore๋ ๊ทผ๊ฑฐ๋ฅผ ๋ณด๊ณ ํ์ง๋ง ์ด Skill์ ์์ ์ฌ๋ถ๋ฅผ ํ๋จํ์ง ์์ต๋๋ค.
๋ณด๊ณ ์ ๋งํฌ ๋ณต์ฌ
https://skillstore.io/skills/samber-golang-structs-interfaces/audits/1?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown ๋ฐฐ์ง
[](https://skillstore.io/skills/samber-golang-structs-interfaces?utm_source=security_passport_badge)HTML ๋ฐฐ์ง
<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>์๋ฒ ๋ ์นด๋
<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>ํ์ ์ธ์ฉ (APA ยท BibTeX ยท CFF)
APA ์ธ์ฉ
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 ์ธ์ฉ
@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 ์ ์
์ด ์ ์์ ์ด์ ์ฆ๊ฑฐ ์ ๋ขฐ๋: ์ค๊ฐ๋ง๋ค ์ ์๋ ๊ฒ
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.
์ด ํ๋กฌํํธ๋ฅผ ์ฌ์ฉํด ๋ณด์ธ์
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.
๋ชจ๋ฒ ์ฌ๋ก
- 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.
ํผํ๊ธฐ
- 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.
์์ฃผ ๋ฌป๋ ์ง๋ฌธ
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?
๊ฐ๋ฐ์ ์ธ๋ถ ์ ๋ณด
์์ฑ์
samber๋ผ์ด์ ์ค
MIT
์์ฑ์ ๋ฒ์
v1.2.1
Skillstore ๋ฆฌ๋น์
r1
๋ฆฌํฌ์งํ ๋ฆฌ
https://github.com/samber/cc-skills-golang/tree/19a0626ae8565d27a7b7bdf59d8d99d94d7e284c/skills/golang-structs-interfaces์ฐธ์กฐ
2aa351cb09c29b7287d263bd8ea81e9bee3b2a61
์ ์ง๋ณด์ ์ต์ ์ฑ
2026. 9. 30.
์ฌ์ฉ๋
0 ๋ค์ด๋ก๋ ยท 0 ์กฐํ
ํ์ผ ๊ตฌ์กฐ
๐ evals/
๐ evals.json
๐ references/
๐ struct-fields.md
๐ type-assertions.md
๐ SKILL.md