📖 About Go
Go (Golang) is a statically typed, compiled programming language designed at Google. It's known for its simplicity, excellent concurrency support with goroutines, and fast compilation. Go excels at building cloud-native applications, microservices, DevOps tools, and high-performance network services.
🎯 Best For
- Cloud-native applications and microservices
- DevOps and infrastructure tools
- Network services and APIs
- Concurrent and parallel processing
- Container orchestration (Docker, Kubernetes)
🔧 Key Features
- Goroutines for lightweight concurrency
- Channels for safe communication between goroutines
- Simple and explicit error handling
- Fast compilation and execution
- Built-in testing and benchmarking
- Garbage collection with low latency
🛠️ Development Tools
Build
go build
Test
go test ./...
Coverage
go test ./... -coverprofile=coverage.out
Run
go run .
📄 Package Contents (7 files)
AGENTS_RULES.md
Complete AI agent rules (universal)
- GOLANG-specific best practices
- TDD workflow (Red-Green-Refactor)
- DDD principles and patterns
- Git workflow and commit format
- Code quality principles
.cursorrules
Quick reference for Cursor IDE
- Essential rules summary
- Links to full documentation
- Optimized for quick loading
.gitignore
Git exclusions
- GOLANG-specific patterns
- Build artifacts
- IDE configuration files
- Dependency directories
AGENTS.md
Quick reference guide
- Common patterns
- Best practices summary
- Quick troubleshooting
README.md
Project template with examples
- Setup instructions
- Sample code and structure
- Testing examples
- Build and run commands
CODE_QUALITY_PRINCIPLES.md
Quality principles and best practices
- Avoid default values (fail-fast)
- Consistency across code paths
- Extract reusable functions
- GOLANG-specific examples
CONTRIBUTING.md
Contribution guidelines
- TDD workflow (Red-Green-Refactor)
- Git commit format
- Code review process
- Testing requirements (90% coverage)
💻 Code Examples
Error Handling
func divide(x, y float64) (float64, error) {
if y == 0 {
return 0, errors.New("division by zero")
}
return x / y, nil
}
result, err := divide(10, 2)
if err != nil {
return fmt.Errorf("calculation failed: %w", err)
}
Goroutines and Channels
func process(items []int) []int {
results := make(chan int, len(items))
for _, item := range items {
go func(i int) {
results <- i * 2
}(item)
}
var output []int
for i := 0; i < len(items); i++ {
output = append(output, <-results)
}
return output
}
Interfaces
type UserRepository interface {
FindByID(ctx context.Context, id string) (*User, error)
Save(ctx context.Context, user *User) error
}
func NewUserService(repo UserRepository) *UserService {
return &UserService{repo: repo}
}