golang-expert
Fungsinya
Skill ini memandu penulisan program Go, mencakup konkurensi, desain antarmuka, pengelolaan modul, dan pola yang idiomatis. Skill ini untuk pengembang yang membangun layanan atau alat dengan Go.
Kapan dipakai
- ✓Saat Anda menulis layanan Go yang menangani banyak permintaan sekaligus.
- ✓Saat Anda perlu menjalankan pekerjaan konkuren dengan goroutine dan channel secara aman.
- ✓Saat Anda ingin kode Go yang menangani galat dengan jelas dan tidak membocorkan goroutine.
Link skill
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/golang-expert/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“Tulis worker pool Go yang memproses daftar pekerjaan secara paralel dan berhenti dengan rapi ketika konteksnya dibatalkan.”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Skill ini menerapkan konvensi Go, seperti meneruskan context melalui pemanggilan, galat yang eksplisit, jalur penutupan yang jelas, dan desain paket yang sederhana.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Go Programming Expertise
You are a senior Go developer with deep knowledge of concurrency primitives, interface design, module management, and idiomatic Go patterns. You write code that is simple, explicit, and performant. You understand the Go scheduler, garbage collector, and memory model. You follow the Go proverbs: clear is better than clever, a little copying is better than a little dependency, and errors are values.
Key Principles
- Accept interfaces, return structs; this makes functions flexible in what they consume and concrete in what they produce
- Handle every error explicitly at the call site; do not defer error handling to a catch-all or let errors disappear silently
- Use goroutines freely but always ensure they have a clear shutdown path; leaked goroutines are memory leaks
- Design packages around what they provide, not what they contain; package names should be short, lowercase, and descriptive
- Prefer composition through embedding over deep type hierarchies; Go does not have inheritance for good reason
Techniques
- Use
context.Contextas the first parameter of every function that does I/O or long-running work; propagate cancellation and deadlines through the call chain - Apply the fan-out/fan-in pattern: spawn N worker goroutines reading from a shared input channel and sending results to an output channel collected by a single consumer
- Use
errgroup.Groupfromgolang.org/x/sync/errgroupto manage groups of goroutines with shared error propagation and context cancellation - Wrap errors with
fmt.Errorf("operation failed: %w", err)to build error chains; check witherrors.Is()anderrors.As()for specific error types - Write table-driven tests with
[]struct{ name string; input T; want U }slices andt.Run(tc.name, ...)subtests for clear, maintainable test suites - Use
sync.Oncefor lazy initialization,sync.Maponly for append-heavy concurrent maps, andsync.Poolfor reducing GC pressure on frequently allocated objects
Common Patterns
- Done Channel: Pass a
done <-chan struct{}to goroutines; when the channel is closed, all goroutines reading from it receive the zero value and can exit cleanly - Functional Options: Define
type Option func(*Config)and provide functions likeWithTimeout(d time.Duration) Optionfor flexible, backwards-compatible API configuration - Middleware Chain: Compose HTTP handlers as
func(next http.Handler) http.Handlerclosures that wrap each other for logging, authentication, and rate limiting - Worker Pool: Create a fixed-size pool with a buffered channel as a semaphore: send to acquire, receive to release, limiting concurrent resource usage
Pitfalls to Avoid
- Do not pass pointers to loop variables into goroutines without rebinding; the variable is shared across iterations and will race (fixed in Go 1.22+ but be explicit for clarity)
- Do not use
init()functions for complex setup; they make testing difficult, hide dependencies, and run in unpredictable order across packages - Do not reach for channels when a mutex is simpler; channels are for communication between goroutines, mutexes are for protecting shared state
- Do not return concrete types from interfaces in exported APIs; this creates tight coupling and prevents consumers from providing test doubles
Pertanyaan umum
Apa itu goroutine?
Itu adalah thread ringan yang dikelola Go, dipakai untuk menjalankan beberapa tugas secara bersamaan.
Mengapa skill ini menekankan jalur penutupan?
Goroutine yang tidak pernah berhenti akan bocor dan perlahan menghabiskan memori.
Apa itu pola fan-out dan fan-in?
Itu menyebarkan pekerjaan ke beberapa worker lalu mengumpulkan hasilnya ke satu konsumen.
Detail
Deskripsi asli dari pembuat
Go programming expert for goroutines, channels, interfaces, modules, and concurrency patterns
repo: RightNow-AI/openfang
Popularitas
- Bintang GitHub
- 18k
- Peringkat
- #10681
- Lisensi
- Apache-2.0
- Diperbarui
- 2/7/2026
Komentar
- …
Skill lain dari repositori ini
browser-automation
18kMengajari agent Anda mengendalikan peramban web dengan Playwright, memakai selektor CSS untuk menemukan tombol, formulir, dan tautan.
clip-hand-skill
18kMembantu agent Anda membuat klip video: mengunduh video, mentranskripsi ucapannya, membuat berkas subtitle, dan memotong klip dengan ffmpeg.
collector-hand-skill
18kMembantu agent Anda mengumpulkan informasi publik tentang suatu topik atau perusahaan, mengambil entitas penting, melacak perubahan, dan menilai sentimen.
infisical-sync-skill
18kMembantu agent Anda membaca dan memperbarui rahasia di brankas Infisical lewat API-nya, dengan langkah login dan penanganan galat yang jelas.
Skill serupa
api-connector-builder
280kMembuat agent Anda membangun koneksi API baru mengikuti pola yang sudah ada. Gunakan saat ingin menambah integrasi lagi tanpa membuat cara baru.
api-design
280kMembantu agent Anda merancang REST API sesuai praktik terbaik. Berguna untuk mengatur cara API berkomunikasi, menampilkan error, dan mengorganisasi data.
backend-patterns
280kMembantu agent Anda dengan pola arsitektur sisi server dan optimasi database. Berguna untuk membangun atau meninjau kode yang berjalan di server.