coding-go
coding-go
Purpose
This skill equips the AI to handle Go programming tasks using features from Go 1.23+, focusing on advanced concurrency, modular code, and robust error management. Use it to generate, debug, and optimize Go code in real-time interactions.
When to Use
Apply this skill for concurrent programming needs, like building scalable servers with goroutines and channels. Use it when developing modular applications with interfaces and generics, or for testing and error-prone codebases in Go 1.23+. Avoid it for basic scripting; opt for other languages if Go's ecosystem isn't required.
Key Capabilities
- Goroutines: Spawn lightweight threads for concurrency; e.g., use
go func() { fmt.Println("Task") }()to run asynchronously. - Channels: Facilitate safe communication between goroutines; declare with
ch := make(chan int)and send/receive viach <- 5or<-ch. - Interfaces: Define contracts for polymorphism; e.g.,
type Writer interface { Write([]byte) error }. - Error Handling: Check errors explicitly, as in
if err != nil { return err }, with support for wrapped errors viaerrors.Is(). - Modules: Manage dependencies with
go mod; initialize viago mod init example.com/project. - Testing: Write unit tests using the
testingpackage; e.g.,func TestAdd(t *testing.T) { if add(1,2) != 3 { t.Error("Failed") } }. - Generics: Use type parameters in functions; e.g.,
func Map[T any](slice []T, f func(T) T) []T { ... }.
Usage Patterns
To implement concurrency, always pair goroutines with channels to avoid race conditions; for example, create a channel first, then launch goroutines that send data to it. For modular code, structure packages with interfaces to decouple dependencies—import modules via go get and use import "example.com/pkg". When handling errors, wrap them for context using fmt.Errorf("wrap: %w", err) and propagate up the call stack. For generics, define type constraints like [T comparable] to ensure type safety in functions. Test code by running go test -v in the package directory after writing tests in _test.go files.
More from alphaonedev/openclaw-graph
playwright-scraper
Playwright web scraping: dynamic content, auth flows, pagination, data extraction, screenshots
1.4Kgcp-iam
Manages identity and access control for Google Cloud resources using IAM policies and roles.
370humanize-ai-text
AI text humanization: reduce AI-detection patterns, natural phrasing, tone adjustment
260macos-automation
AppleScript, JXA, Shortcuts, Automator, osascript, System Events, accessibility API
173tavily-web-search
Tavily: web search optimized for AI agents, answer synthesis, domain filtering, depth control
155clawflows
OpenClaw workflow automation: multi-step task chains, conditional logic, triggers, schedule
102