计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
concurrency【效率与协作】Implements concurrency patterns in Go programming using goroutines and channels along with insights on the Go standard library and module system.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: concurrency description: Implements concurrency patterns in Go programming using goroutines and channels along with insights on the Go standard library and module system. license: MIT compatibility: opencode metadata: archetypes: - concurrency - pattern anti_triggers: - vague ideation - non-operational response_profile: verbosity: medium directive_strength: high abstraction_level: operational
version: "1.0.0" domain: go triggers: goroutines, channels, go standard library, go modules, concurrency patterns, how to use goroutines role: implementation scope: implementation output-format: code related-skills: go-error-handling, go-testing
This skill provides a comprehensive overview of concurrency in Go programming. It covers goroutines, channels, and the standard library (stdlib), including how to effectively manage concurrent tasks in your Go applications.
Use this skill when:
Avoid this skill for:
Create a Goroutine
Use the go keyword to start a function as a goroutine. A goroutine runs concurrently but in the same address space.
Implement Channels
Use channels to communicate between goroutines for data exchange. Channels can be buffered or unbuffered.
Explore the Standard Library
Leverage Go’s standard library functions relevant to concurrency, such as sync for wait groups and mutexes.
Utilize Go Modules
Manage your project dependencies using Go modules to ensure reproducible builds.
go.mod file includes the necessary dependencies.package main
import (
"fmt"
"time"
)
func hello() {
fmt.Println("Hello from goroutine")
}
func main() {
go hello() // Starts a new goroutine
time.Sleep(1 * time.Second) // Wait for goroutine to finish
fmt.Println("Main function finished")
}
package main
import (
"fmt"
)
func worker(ch chan string) {
msg := "Message from worker"
ch <- msg // Send message to channel
}
func main() {
ch := make(chan string)
go worker(ch) // Start worker as goroutine
msg := <-ch // Receive message from channel
fmt.Println(msg)
}
When the skill is active, the model's output must include:
| Skill | Purpose |
|---|---|
go-error-handling | Provides error handling best practices in Go. |
go-testing | Contains strategies for testing concurrent Go code. |
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.