← ClaudeAtlas

go-devlisted

Use when the user asks to implement, refactor, test, debug, or review Go code, Go modules, error handling, concurrency, interfaces, generics, or go test/build/vet failures.
iamtatsuki05/dotfiles · ★ 0 · Code & Development · score 56
Install: claude install-skill iamtatsuki05/dotfiles
# Go開発スキル Goコードの実装、テスト、デバッグ、リファクタリングを効率的に行うためのガイド。 ## 実装前の必須確認 **go.mod と Makefile を必ず確認する。** プロジェクトのGoバージョン、依存関係、ビルド手順を把握する。 確認項目: - `go.mod`: Goバージョン(1.21+推奨)、依存ライブラリ - `Makefile`: ビルド、テスト、lint コマンド - `.golangci.yml`: linter設定(存在する場合) - 既存の package 構成、テストヘルパー、エラー処理、context の使い方 - `Makefile` がない場合は `go test ./...`、`go test ./path`、`go vet ./...` など標準コマンドを確認する ### プロジェクト構造例 ``` project/ ├── src/ # メインソースコード │ ├── main.go │ └── project/ │ ├── config/ │ ├── common/utils/ │ ├── env.go │ └── env_test.go ├── config/ # 設定ファイル ├── docker/ # Dockerfile等 ├── docs/ # ドキュメント ├── go.mod ├── go.sum ├── Makefile └── compose.yml ``` ## コーディング規約 ### 基本スタイル ```go // パッケージ名はディレクトリ名と一致、小文字のみ package user import ( "context" "errors" "fmt" ) // 公開型はPascalCase、非公開はcamelCase type User struct { ID int64 Name string Email string CreatedAt time.Time } // コンストラクタ関数 func NewUser(name, email string) *User { return &User{ Name: name, Email: email, CreatedAt: time.Now(), } } // メソッドレシーバは短い名前(1-2文字) func (u *User) Validate() error { if u.Name == "" { return errors.New("name is required") } return nil } ``` ### エラーハンドリング ```go // エラーは最後の戻り値 func FindUser(ctx context.Context, id int64) (*User, error) { user, err := db.Get(ctx, id) if err != nil { // エラーをラップして文脈を追加 return n