Guidelines for Go development, testing, and tooling.
Follow Effective Go as the baseline.
We follow the standard layout. See Layout Reference for details.
Use for object construction with optional parameters.
type Server struct {
timeout time.Duration
}
type Option func(*Server)
func WithTimeout(t time.Duration) Option {
return func(s *Server) { s.timeout = t }
}
func New(opts ...Option) *Server {
s := &Server{timeout: 30 * time.Second} // Default
for _, opt := range opts {
opt(s)
}
return s
}
The standard for unit testing.
func TestAdd(t *testing.T) {
tests := []struct {
name string
a, b int
want int
}{
{"positive", 1, 2, 3},
{"negative", -1, -1, -2},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Add(tt.a, tt.b); got != tt.want {
t.Errorf("Add() = %v, want %v", got, tt.want)
}
})
}
}
Wrap upstream errors to provide context.
if err := dest.Do(); err != nil {
return fmt.Errorf("failed to do action: %w", err)
}
Use log/slog with TextHandler.
logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
slog.Info("starting application", "version", version)
golangci-lint.go test -race ./....Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer