SKILL.md--- name: go-mod-helper description: Go module system, dependency management, and project configuration assistance. --- # Go Module Management Skill Go module system, dependency management, and project configuration assistance. ## Instructions You are a Go module and dependency expert. When invoked: 1. **Module Management**: - Initialize and configure Go modules - Manage go.mod and go.sum files - Handle module versioning and dependencies - Work with module replacements and exclusions - Configure module proxies and checksums 2. **Dependency Management**: - Add, update, and remove dependencies - Handle indirect dependencies - Resolve version conflicts - Use semantic import versioning - Manage private modules 3. **Project Setup**: - Initialize new Go projects - Configure project structure - Set up multi-module repositories - Configure build tags and constraints - Manage workspace mode 4. **Troubleshooting**: - Fix module resolution errors - Debug checksum mismatches - Resolve import path issues - Handle proxy and authentication problems - Clean corrupted module cache 5. **Best Practices**: Provide guidance on Go module patterns, versioning, and dependency management ## Go Module Basics ### Module Initialization ```bash # Initialize new module go mod init github.com/username/project # Initialize with custom path go mod init example.com/myproject # Create project structure mkdir -p cmd/server internal/api pkg/utils touch cmd/server/main.go # Sample main.go cat > cmd/server/main.go << 'EOF' package main import ( "fmt" "github.com/username/project/internal/api" ) func main() { fmt.Println("Hello, Go modules!") api.Start() } EOF ``` ### go.mod File Structure ```go module github.com/username/project go 1.21 require ( github.com/gin-gonic/gin v1.9.1 github.com/lib/pq v1.10.9 golang.org/x/sync v0.5.0 ) require ( // Indirect dependencies github.com/bytedance/sonic v1.10.2 // indirect github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect ) replace ( // Replace with local version github.com/old/package => ../local/package // Replace with fork github.com/original/repo => github.com/fork/repo v1.2.3 ) exclude ( // Exclude problematic versions github.com/bad/package v1.2.3 ) retract ( // Retract published versions v1.5.0 // Contains bug [v1.6.0, v1.6.5] // Range of bad versions ) ``` ### go.sum File ``` github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= ``` ## Usage Examples ``` @go-mod-helper @go-mod-helper --init-project @go-mod-helper --update-deps @go-mod-helper --tidy @go-mod-helper --troubleshoot @go-mod-helper --private-modules ``` ## Common Commands ### Dependency Management ```bash # Add dependency (automatically) # Just import and run: go get github.com/gin-gonic/gi