golang-patterns
Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable Go applications.
Skill by Luohaothu
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/luohaothu-golang-patterns-cd144f
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
golang-patterns- Description
- Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable Go applications.
- License
- MIT
- Instructions
- 670 lines in SKILL.md · view on GitHub
Before installing
- Instructions call the network
Agent Skills spec issues
- body: 670 lines (spec recommends under 500)
Files (1)
- SKILL.md
SKILL.md (first lines)
# Go 開發模式
用於建構穩健、高效且可維護應用程式的慣用 Go 模式和最佳實務。
## 何時啟用
- 撰寫新的 Go 程式碼
- 審查 Go 程式碼
- 重構現有 Go 程式碼
- 設計 Go 套件/模組
## 核心原則
### 1. 簡單與清晰
Go 偏好簡單而非聰明。程式碼應該明顯且易讀。
```go
// 良好:清晰直接
func GetUser(id string) (*User, error) {
user, err := db.FindUser(id)
if err != nil {
return nil, fmt.Errorf("get user %s: %w", id, err)
}
return user, nil
}
// 不良:過於聰明
func GetUser(id string) (*User, error) {
return func() (*User, error) {
if u, e := db.FindUser(id); e == nil {
return u, nil
} else {
return nil, e
}
}()
}
```
### 2. 讓零值有用
設計類型使其零值無需初始化即可立即使用。
```go
// 良好:零值有用
type Counter struct {
mu sync.Mutex
count int // 零值為 0,可直接使用
}
func (c *Counter) Inc() {
c.mu.Lock()
c.count++
c.mu.Unlock()
}
// 良好:bytes.Buffer 零值可用
var buf bytes.Buffer
buf.WriteString("hello")
// 不良:需要初始化
type BadCounter struct {
counts map[string]int // nil map 會 panic
}
```
### 3. 接受介面,回傳結構
函式應接受介面參數並回傳具體類型。
```go
// 良好:接受介面,回傳具體類型
func ProcessData(r io.Reader) (*Result, error) {
data, err := io.ReadAll(r)
if err != nil {
return nil, err
}
return &Result{Data: data}, nil
}
// 不良:回傳介面(不必要地隱藏實作細節)
func ProcessData(r io.Reader) (io.Reader, error) {
// ...
}
```
## 錯誤處理模式
### 帶上下文的錯誤包裝
```go
// 良好:包裝錯誤並加上上下文
func LoadConfig(path string) (*Config, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("load config %s: %w", path, err)
}
var cfg Config
if err := json.Unmarshal(data, &cfg); err != nil {
return nil, fmt.Errorf("parse config %s: %w", path, err)
}
return &cfg, nil
}
```
### 自訂錯誤類型
```go
// 定義領域特定錯誤
type ValidationError struct {
Field string
Message string
}
func (e *ValidationError) Error() string {
return fmt.Sprintf("validation failed on %s: %s", e.Field, e.Message)
}From Luohaothu/everything-codex, MIT.
More from Luohaothu/everything-codex
- 0.493score
architect
Luohaothu
Software architecture specialist for system design, scalability, and technical decision-making.
SkillDFreshness: D★ 26Claude Code +9 - 0.493score
build-fix
Luohaothu
Build and compilation error resolution specialist.
SkillDFreshness: D★ 26Claude Code +9 - 0.490score
code-review
Luohaothu
Expert code review for quality, security, and maintainability.
SkillDFreshness: D★ 26Claude Code +9 - 0.490score
checkpoint
Luohaothu
Create or verify workflow checkpoints using git commits and state tracking.
SkillDFreshness: D★ 26Claude Code +9 - 0.487score
tdd-workflow
Luohaothu
在编写新功能、修复错误或重构代码时使用此技能。强制执行测试驱动开发,包含单元测试、集成测试和端到端测试,覆盖率超过80%。
SkillDFreshness: D★ 26Claude Code +9 - 0.487score
springboot-security
Luohaothu
Java Spring Boot 服务中关于身份验证/授权、验证、CSRF、密钥、标头、速率限制和依赖安全的 Spring Security 最佳实践。
SkillDFreshness: D★ 26Claude Code +9 - 0.487score
springboot-tdd
Luohaothu
使用JUnit 5、Mockito、MockMvc、Testcontainers和JaCoCo进行Spring Boot的测试驱动开发。适用于添加功能、修复错误或重构时。
SkillDFreshness: D★ 26Claude Code +9 - 0.487score
springboot-patterns
Luohaothu
Spring Boot 架构模式、REST API 设计、分层服务、数据访问、缓存、异步处理和日志记录。适用于 Java Spring Boot 后端工作。
SkillDFreshness: D★ 26Claude Code +9 - 0.484score
jpa-patterns
Luohaothu
Spring Boot中的JPA/Hibernate实体设计、关系、查询优化、事务、审计、索引、分页和连接池模式。
SkillDFreshness: D★ 26Claude Code +9 - 0.484score
postgres-patterns
Luohaothu
基于Supabase最佳实践的PostgreSQL数据库模式,用于查询优化、架构设计、索引和安全。
SkillDFreshness: D★ 26Claude Code +9 - 0.484score
eval-harness
Luohaothu
克劳德代码会话的正式评估框架,实施评估驱动开发(EDD)原则
SkillDFreshness: D★ 26Claude Code +9 - 0.484score
continuous-learning-v2
Luohaothu
基于本能的学习系统,通过钩子观察会话,创建具有置信度评分的原子本能,并将其演化为技能/命令/代理。
SkillDFreshness: D★ 26Claude Code +9
Signals
- Stars
- 26
- Forks
- 5
- Open issues
- 0
- Last commit (this folder)
- Jan 29, 2026 (9 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/Luohaothu/everything-codex
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
- 0.399score
golang-patterns
vibeeval
Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable Go applications.
SkillDFreshness: D★ 540Claude Code +9 - 0.355score
golang-patterns
sazardev
Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable Go applications.
SkillCFreshness: C★ 304Claude Code +9 - 0.301score
golang-patterns
ViewWay
Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable Go applications.
SkillCFreshness: C★ 3Claude Code +9 - 0.271score
golang-patterns
chaitin
Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable Go applications.
SkillDFreshness: D★ 7Claude Code +9
More from Luohaothu
- 0.493score
architect
Luohaothu
Software architecture specialist for system design, scalability, and technical decision-making.
SkillDFreshness: D★ 26Claude Code +9 - 0.493score
build-fix
Luohaothu
Build and compilation error resolution specialist.
SkillDFreshness: D★ 26Claude Code +9 - 0.490score
code-review
Luohaothu
Expert code review for quality, security, and maintainability.
SkillDFreshness: D★ 26Claude Code +9 - 0.490score
checkpoint
Luohaothu
Create or verify workflow checkpoints using git commits and state tracking.
SkillDFreshness: D★ 26Claude Code +9 - 0.487score
springboot-patterns
Luohaothu
Spring Boot 架构模式、REST API 设计、分层服务、数据访问、缓存、异步处理和日志记录。适用于 Java Spring Boot 后端工作。
SkillDFreshness: D★ 26Claude Code +9 - 0.487score
springboot-security
Luohaothu
Java Spring Boot 服务中关于身份验证/授权、验证、CSRF、密钥、标头、速率限制和依赖安全的 Spring Security 最佳实践。
SkillDFreshness: D★ 26Claude Code +9
Cite this page
golang-patterns skill. Agent Mart. https://agentmart.dev/skills/luohaothu-golang-patterns-cd144f (last updated 2026-10-24)