golang-patterns
Officialİdiomatic Go desenler, en iyi uygulamalar ve sağlam, verimli ve bakımı kolay Go uygulamaları oluşturmak için konvansiyonlar.
What this skill does
When applied, it prepends a system prompt before your request is sent — no extra calls and no change to how you are billed beyond the added tokens.
---
name: golang-patterns
description: İdiomatic Go desenler, en iyi uygulamalar ve sağlam, verimli ve bakımı kolay Go uygulamaları oluşturmak için konvansiyonlar.
origin: ECC
---
# Go Geliştirme Desenleri
Sağlam, verimli ve bakımı kolay uygulamalar oluşturmak için idiomatic Go desenleri ve en iyi uygulamalar.
## Ne Zaman Etkinleştirmeli
- Yeni Go kodu yazarken
- Go kodunu gözden geçirirken
- Mevcut Go kodunu refactor ederken
- Go paketleri/modülleri tasarlarken
## Temel Prensipler
### 1. Basitlik ve Açıklık
Go, zekiceden ziyade basitliği tercih eder. Kod açık ve okunması kolay olmalıdır.
```go
// İyi: Açık ve doğrudan
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
}
// Kötü: Aşırı zeki
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. Sıfır Değeri Kullanışlı Yapın
Türleri, sıfır değerinin başlatma olmadan hemen kullanılabilir olacağı şekilde tasarlayın.
```go
// İyi: Sıfır değer kullanışlıdır
type Counter struct {
mu sync.Mutex
count int // sıfır değer 0'dır, kullanıma hazırdır
}
func (c *Counter) Inc() {
c.mu.Lock()
c.count++
c.mu.Unlock()
}
// İyi: bytes.Buffer sıfır değerle çalışır
var buf bytes.Buffer
buf.WriteString("hello")
// Kötü: Başlatma gerektirir
type BadCounter struct {
counts map[string]int // nil map panic verir
}
```
### 3. Interface Kabul Et, Struct Döndür
Fonksiyonlar interface parametreleri kabul etmeli ve somut tipler döndürmelidir.
```go
// İyi: Interface kabul eder, somut tip döndürür
func ProcessData(r io.Reader) (*Result, error) {
data, err := io.ReadAll(r)
if err != nil {
return nil, err
}
return &Result{Data: data}, nil
}
// Kötü: Interface döndürür (implementasyon detayUse this skill
Add a "skill" field with the skill’s ID to your chat completion request. It is applied server-side before your prompt is sent — no extra calls.
{
"model": "gpt-4o-mini",
"skill": "imp-1fb27f7a-653e-4fef-84e6-1eb6862a5003",
"messages": [{ "role": "user", "content": "…" }]
}Install the skill, enable it in your dashboard and (optionally) limit it to specific models. It then applies automatically to every matching request — with no "skill" field to send each time.
Set it up in your dashboardMore skills
Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.
Create, view, edit, delete, search, move, or export Apple Notes via the memo CLI on macOS.
List, add, edit, complete, or delete Apple Reminders and reminder lists via remindctl.
Create, search, and manage Bear notes via grizzly CLI.
Monitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.
BluOS CLI (blu) for discovery, playback, grouping, and volume.
Capture frames or clips from RTSP/ONVIF cameras.
Search, install, update, sync, or publish agent skills with the ClawHub CLI and registry.