Skip to content

SurajKadam7/buddy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Buddy - Go Template Generator

Go Version Test Coverage Thread Safe License: MIT

Buddy is a powerful, thread-safe CLI tool that helps Go developers quickly generate project templates, manage custom files, and streamline development workflow.

✨ Features

  • πŸ—οΈ Multiple Template Strategies: Simple, project, and advanced Go templates
  • πŸ“‚ Named File Management: Create and manage custom files with unique numbering
  • ⚑ Editor Integration: Auto-open files in your favorite editor (VS Code, Vim, etc.)
  • πŸ” File Operations: Delete, rename, and search through your created files
  • πŸ’Ύ Persistent Configuration: Your settings are saved automatically
  • 🌍 Global Installation: Install buddy globally for system-wide access
  • πŸ”’ Thread Safe: Concurrent operations with zero race conditions
  • πŸ§ͺ High Test Coverage: 86.7% test coverage with comprehensive edge cases

πŸ“‹ Requirements

  • Go: 1.21.5 or higher
  • OS: macOS, Linux, Windows
  • Memory: Minimal (typically < 10MB)
  • Dependencies: Automatically managed via Go modules

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/SurajKadam7/buddy.git
cd buddy

# Build the binary
go build .

# Install globally (optional - requires sudo on Unix systems)
./buddy install

Verify Installation

# Check version
./buddy version

# View help
./buddy --help

# Check status
./buddy status

Basic Usage

# Create templates
buddy create                    # Use default strategy
buddy create --simple           # Single Go file
buddy create --project          # Full Go project structure
buddy create --advanced         # Project with tooling (Makefile, etc.)

# Create custom named files
buddy create --name my-algorithm
buddy create --name api-client

# Manage your files
buddy list named                # List all named files
buddy open 1                    # Open file #1
buddy rename 1 new-name         # Rename file #1
buddy delete 2                  # Delete file #2
buddy search "TODO"             # Search in files

# Configure buddy
buddy set-editor code           # Set VS Code as editor
buddy set-path ~/my-projects    # Set output directory
buddy set-strategy project      # Set default strategy
buddy toggle-auto-open          # Toggle auto-open in editor

πŸ“‹ Commands Reference

Template Creation

  • buddy create - Create template with default strategy
  • buddy create --simple - Single Go file with basic structure
  • buddy create --project - Go project with cmd/, internal/, pkg/ structure
  • buddy create --advanced - Full project with Makefile, .gitignore, etc.
  • buddy create --name <filename> - Create custom named file

File Management

  • buddy list named - List all custom named files
  • buddy open <number> - Open and activate a named file
  • buddy delete <number> - Delete a named file
  • buddy rename <number> <new-name> - Rename a named file
  • buddy search <term> - Search for files containing a term

Configuration

  • buddy status - Show current configuration and stats
  • buddy config - Display detailed configuration
  • buddy set-editor <editor> - Set default editor (code, vim, etc.)
  • buddy set-path <path> - Set output directory for generated files
  • buddy set-strategy <strategy> - Set default template strategy
  • buddy toggle-auto-open - Toggle auto-open files in editor

System & Analysis

  • buddy install - Install buddy globally
  • buddy space - Analyze library space consumption
  • buddy version - Show version information
  • buddy --help - Show help for any command

🎯 Template Strategies

Simple

Creates a single Go file with:

  • Basic package structure
  • Simple function template
  • Ready to run

Project

Creates a complete Go project with:

  • cmd/ directory with main.go
  • internal/ for private packages
  • pkg/ for public packages
  • go.mod file
  • Basic README

Advanced

Creates a professional Go project with:

  • Complete project structure
  • Makefile with build targets
  • .gitignore file
  • CI/CD ready structure
  • Documentation templates

πŸ”§ Configuration

Buddy stores configuration in ~/.buddy-config.json:

{
  "output_path": "/Users/username/buddy-projects",
  "default_strategy": "project", 
  "editor": "code",
  "auto_open": true,
  "editor_profiles": {
    "code": "code",
    "vim": "vim",
    "nano": "nano"
  }
}

Supported Editors

  • VS Code: code
  • Vim/Neovim: vim, nvim
  • Nano: nano
  • Emacs: emacs
  • Custom: Any command-line editor

πŸš€ Performance & Reliability

Thread Safety

  • Zero race conditions with comprehensive mutex implementation
  • Concurrent file operations supported safely
  • Data integrity guaranteed under load

Performance Metrics

  • File Creation: ~3ms for complex templates
  • Search Operations: Sub-second for thousands of files
  • Memory Usage: < 10MB typical usage
  • Startup Time: < 100ms

Test Coverage

  • 86.7% overall coverage across all packages
  • Comprehensive edge case testing
  • Mock-based testing for system operations
  • Benchmark testing for performance validation

πŸ’‘ Tips & Tricks

  1. Quick File Creation: Use buddy create --name <n> for rapid prototyping
  2. Search Everything: Use buddy search to find files by name or content with fuzzy matching
  3. Editor Integration: Set your favorite editor with buddy set-editor
  4. Project Organization: Use different output paths for different projects
  5. Auto-numbering: Named files are automatically numbered for easy reference
  6. Space Monitoring: Use buddy space to track library usage
  7. Batch Operations: Rename/delete multiple files efficiently

🎨 Named Files Workflow

Named files are perfect for algorithm practice, quick experiments, or code snippets:

# Create algorithm files
buddy create --name binary-search
buddy create --name quick-sort
buddy create --name graph-traversal

# List and work with them
buddy list named
buddy open 2              # Opens quick-sort
buddy search "recursive"   # Find files with recursion

# Get file statistics
buddy space              # See space usage

The personalize/main.go automatically updates to run your selected file.

🌟 Example Workflow

# Set up your environment
buddy set-editor code
buddy set-path ~/coding-practice

# Create some files
buddy create --name fibonacci
buddy create --name prime-numbers
buddy create --name binary-tree

# Work on fibonacci
buddy open 1

# Search for specific implementations
buddy search "recursive"

# Rename and organize
buddy rename 1 fibonacci-optimized
buddy delete 2

# Create a full project
buddy create --project

# Monitor usage
buddy space
buddy status

πŸ”§ Troubleshooting

Common Issues

Permission denied during global install:

# Try with sudo (Unix systems)
sudo ./buddy install

# Or install to user directory
mkdir -p ~/.local/bin
cp buddy ~/.local/bin/
export PATH="$HOME/.local/bin:$PATH"

Editor not opening files:

# Check editor availability
which code
which vim

# Reset editor configuration
buddy set-editor code

Files not found:

# Check current configuration
buddy status
buddy config

# Verify file list
buddy list named

Build issues:

# Clean and rebuild
go clean
go mod tidy
go build .

Getting Help

  • Command help: buddy <command> --help
  • General help: buddy --help
  • Status check: buddy status
  • Configuration: buddy config

πŸ§ͺ Development & Testing

Running Tests

# Run all tests
go test ./...

# Run with coverage
go test -cover ./...

# Run with race detection
go test -race ./...

# Run benchmarks
go test -bench=. ./...

Build from Source

git clone https://github.com/SurajKadam7/buddy.git
cd buddy
go mod tidy
go build .

🀝 Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes with tests
  4. Run the test suite: go test ./...
  5. Ensure good coverage: go test -cover ./...
  6. Check for race conditions: go test -race ./...
  7. Commit your changes: git commit -m 'Add amazing feature'
  8. Push to the branch: git push origin feature/amazing-feature
  9. Open a Pull Request

Development Guidelines

  • Maintain thread safety with proper mutex usage
  • Add comprehensive tests for new features
  • Follow Go best practices and idioms
  • Update documentation as needed
  • Ensure backward compatibility

πŸ“ˆ Changelog

v1.0.0

  • βœ… Thread-safe operations with zero race conditions
  • βœ… 86.7% test coverage achievement
  • βœ… Mock-based testing for system operations
  • βœ… Comprehensive error handling
  • βœ… Performance optimizations
  • βœ… Enhanced search functionality with fuzzy matching
  • βœ… Space analysis feature

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with Cobra for CLI framework
  • Uses Fuzzy for search functionality
  • Inspired by the Go community's need for rapid prototyping tools

Made with ❀️ for Go developers

"Streamline your Go development workflow with Buddy!"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors