← ClaudeAtlas

go-service-conventionslisted

Team conventions for Go services - code formatting (blank line before return, guard returns, logical blocks), the required library stack, and the project directory layout. Use when writing, editing, reviewing or scaffolding Go service code.
saturngfish/go-claude-skill · ★ 0 · Code & Development · score 62
Install: claude install-skill saturngfish/go-claude-skill
# Go service conventions Apply these rules whenever you write, edit, review or scaffold Go code for a service. ## 1. Code formatting ### Rules 1. **Blank line before `return`** when the `return` follows one or more statements inside the same block. 2. **Guard return** (an early exit that is the only line inside an `if`) is written **without** a blank line. The body of the condition already isolates it. 3. **Logical blocks** inside a function (declaration → computation → return) are separated by blank lines. 4. One-line wrapper functions (`func X() T { return ... }`) are fine and stay on one line. ### Good ```go func EncodeBattle(id int64) string { return Encode(Battle, id) } func EncodeItem(id int64) string { return Encode(Item, id) } if resp.IsError() { if resp.Error != nil && resp.Error.Message == msgNotEnoughFunds { return true, nil } return false, types.NewServiceError(types.ErrorServerError, "WITHDRAW_FAILED") } func isUsdStablecoin(symbol string) bool { _, ok := usdStablecoins[strings.ToUpper(strings.TrimSpace(symbol))] return ok } func ConvertUsdToActiveCrypto(priceUsd float64, targetSymbol string) (float64, error) { // ...other code result, err := prices.Default.Convert(ctx, decimal.NewFromFloat(priceUsd), "USD", targetSymbol) if err != nil { return 0, err } f, _ := result.Float64() return f, nil } func Roll(serverSeed, clientSeed string, nonce int64) uint64 { h := hmac.New(sha256.New, []byte(serverSeed)) h.Write([]byte(clientSeed))