ワンクリックで
go-best-practices
Go coding standards, error handling, concurrency, and Connect-RPC conventions for the Omega project
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Go coding standards, error handling, concurrency, and Connect-RPC conventions for the Omega project
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use whenever the user wants to run, plan, kick off, iterate on, or close out a Victoria training version (e.g. "let's start V200", "next training run", "kick off the next iteration", "what should we try next for Victoria", "ship V###", "log this training run"). Codifies the continual-improvement loop — read the latest entry in omega/nodes/victoria/training_log/, propose the next version's hypothesis, run the gates, write the new V###.md entry, update the high-water table, commit, and push.
Structured research pipeline for Omega — takes an idea or hypothesis, searches for evidence, compares to existing Omega capabilities, and delivers a verdict with implementation recommendations. Use when asked to /research a topic, evaluate a new signal source, assess an external tool/library, or investigate trading strategies.
IterDRAG iterative retrieval-augmented generation pattern — search, summarize, reflect loop for deep research tasks
Buf conventions, proto3 best practices, schema evolution rules, and Connect-ES v2 frontend patterns for Omega
Go table-driven tests, Python pytest patterns, React Testing Library, property-based testing, and integration test conventions for Omega
| name | go-best-practices |
| description | Go coding standards, error handling, concurrency, and Connect-RPC conventions for the Omega project |
| tags | ["go","golang","error-handling","concurrency","connect-rpc","protobuf"] |
error as the last return value. Never panic unless it is truly unrecoverable.fmt.Errorf("operation: %w", err) — use %w (not %v) to preserve the error chain for errors.Is / errors.As.errors.Is / errors.As for inspection, never string comparison.var ErrFoo = errors.New("foo") at package level.return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("node_id required"))
Connect error codes:
| Code | When to use |
|---|---|
CodeInvalidArgument | Bad input from client |
CodeNotFound | Resource doesn't exist |
CodeAlreadyExists | Resource exists, can't create again |
CodePermissionDenied | Authenticated but not authorized |
CodeUnauthenticated | Not authenticated |
CodeInternal | Unexpected server error (log these) |
CodeUnavailable | Temporary outage, client should retry |
PascalCase. Unexported: camelCase.-er suffix where possible (BrainAdapter, NodeRunner).NodeID, RPCURL, HTTPClient.TestFunctionName_Scenario.node.ID over node.NodeID.internal/ for packages that must not be imported outside the module.cmd/ for entry points only — minimal logic, delegate to internal/.gen/go/ — never edit manually.func (h *NodeHandler) Execute(
ctx context.Context,
req *connect.Request[omegav1.ExecuteRequest],
) (*connect.Response[omegav1.ExecuteResponse], error) {
if req.Msg.NodeId == "" {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("node_id required"))
}
result, err := h.node.Execute(ctx, req.Msg)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
return connect.NewResponse(&omegav1.ExecuteResponse{Result: result}), nil
}
sync.Mutex or sync.RWMutex. Keep critical sections short.context.Context for cancellation — always the first parameter of functions that do I/O.sync.WaitGroup or channel drain).select with ctx.Done() for timeout/cancellation; select with default for non-blocking.tests := []struct {
name string
a, b float64
want float64
}{
{"positive", 3, 4, 7},
{"zero", 0, 5, 5},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := Add(tt.a, tt.b)
if got != tt.want {
t.Errorf("got %v, want %v", got, tt.want)
}
})
}
t.Helper() in test helpers so failure lines point to the caller.t.Skip("requires OMEGA_API_ADDR").golangci-lint run before committing.StateStore — never mutate in-memory state without persisting.context.Context using the tracing package helpers.buf.build/connectrpc/go generated stubs — Connect handles HTTP/1.1 and HTTP/2 transparently.buf generate from repo root after any .proto change.