Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

github.com/SurajKadam7/buddy

Package Overview
Dependencies
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/SurajKadam7/buddy

Source
Go Modules
Version
v0.0.0-20250723180815-cbaa1739c1c8
Version published
Created
Source

🚀 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

  • Quick File Creation: Use buddy create --name <n> for rapid prototyping
  • Search Everything: Use buddy search to find files by name or content with fuzzy matching
  • Editor Integration: Set your favorite editor with buddy set-editor
  • Project Organization: Use different output paths for different projects
  • Auto-numbering: Named files are automatically numbered for easy reference
  • Space Monitoring: Use buddy space to track library usage
  • 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:

  • Fork the repository
  • Create a feature branch: git checkout -b feature/amazing-feature
  • Make your changes with tests
  • Run the test suite: go test ./...
  • Ensure good coverage: go test -cover ./...
  • Check for race conditions: go test -race ./...
  • Commit your changes: git commit -m 'Add amazing feature'
  • Push to the branch: git push origin feature/amazing-feature
  • 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!"

FAQs

Package last updated on 23 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts