A command-line tool to quickly initialize Go projects with pre-configured architectures and templates.
- Initialize Go projects with predefined architecture templates
- Automatic module name replacement throughout the project
- Support for multiple architecture patterns
- Simple CLI interface
- Detailed processing logs
go install github.com/openframebox/goinit@latestOr build from source:
git clone https://github.com/openframebox/goinit.git
cd goinit
go build -o goinitThen move the binary to your PATH:
# On macOS/Linux
sudo mv goinit /usr/local/bin/
# Or add to your PATH in ~/.bashrc or ~/.zshrc
export PATH=$PATH:/path/to/goinitgoinit --helpCheck your installed version:
goinit version
# Output: goinit version 1.0.0Display the current version of goinit:
goinit versionView all available project templates:
goinit listOutput:
Available Architectures:
┌─ layered@v0
│ Name: Layered Architecture (Pre-release)
│ Description:
│ Simple go project with layered architecture. Focus on simplicity and
│ ease of use for small-medium projects.
└─
Usage:
goinit create --project <dir> --module <name> --architecture <arch>
Create a new Go project with a specific architecture:
goinit create --project myapp --module github.com/username/myapp --architecture layered@v0Flags:
--projector-p: Directory path where the project will be created (required)--moduleor-m: Go module name (required)--architectureor-a: Architecture template to use (required)
# Create a new project called "myapi"
goinit create \
--project myapi \
--module github.com/myusername/myapi \
--architecture layered@v0
# Output:
# Creating new project: github.com/myusername/myapi
# Architecture: Layered Architecture (Pre-release)
# Target directory: myapi
#
# Downloading template from https://github.com/...
# Downloaded 30539 bytes
# Extracting template...
# Extraction complete
# Processing template files...
#
# Processing file: .env.example (replaced module name)
# Processing file: .gitignore
# Processing file: README.md (replaced module name)
# ...
#
# ✓ Processed 64 files (28 files with module name replacements)
#
# ✓ Project created successfully at myapi
#
# Next steps:
# cd myapi
# go mod tidyAfter creation, navigate to your project and install dependencies:
cd myapi
go mod tidyA simple layered architecture pattern focused on simplicity and ease of use for small to medium projects. Includes:
- Configuration management
- Repository pattern
- Service layer
- HTTP routing with Fiber
- Authentication middleware
- Database integration (GORM)
- Event system
- Queue system
- Email support
- Storage abstraction
- Go 1.25.0 or higher
- Internet connection (to download templates)
- Load Configuration: Reads available architectures from embedded
goinit.json - Validate Input: Ensures the target directory is empty and architecture exists
- Download Template: Fetches the template archive from GitHub
- Extract Files: Extracts the archive to a temporary location
- Process Files: Recursively processes all files, replacing module placeholders
- Copy to Target: Moves processed files to your project directory
- Cleanup: Removes temporary files
Templates are configured in goinit.json:
{
"availableArchitectures": [
"layered@v0"
],
"boilerplates": {
"layered@v0": {
"name": "Layered Architecture (Pre-release)",
"description": "Simple go project with layered architecture...",
"archiveUrl": "https://github.com/openframebox/goinit-layered/archive/refs/tags/v0.0.0.tar.gz",
"modulePlaceholder": "mymodule"
}
}
}Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Open an issue on GitHub
- Check existing issues for solutions
- Support for custom template repositories
- Interactive mode for project creation
- Template versioning support
- Custom placeholder configuration
- Project update capabilities
Developed by the OpenFrameBox team.