A cross-platform printing service built with Go and Gin framework. This application provides REST API endpoints for managing printers, print configurations, and print jobs.
- List available printers
- Get and set print configurations
- Submit print jobs
- Clear print cache
- Cross-platform support (macOS, Linux, Windows)
- RESTful API with CORS support
- Go 1.23 or later
- CUPS (on macOS/Linux) or Windows printing services
git clone https://github.com/lkphuong/go-printer.git
cd go-printergo mod downloadmake runOr directly:
go run ./cmd/server/main.goThe server will start on port 9099.
# Build for Windows
make build-windows
# Build for macOS (ARM64)
make build-macDownload the pre-built binaries from the build folder:
All endpoints are prefixed with /api/v1.
GET /printers- Get list of available printersGET /printers/:printer/config- Get print configuration for a specific printerPOST /printers/config- Configure a printerPOST /printers/jobs- Submit a print jobDELETE /printers/cache- Clear print cache
# Get printers
curl http://localhost:9099/api/v1/printers
# Get config for a printer
curl http://localhost:9099/api/v1/printers/MyPrinter/config
# Submit a print job (example payload)
curl -X POST http://localhost:9099/api/v1/printers/jobs \
-H "Content-Type: application/json" \
-d '{"printer": "MyPrinter", "file": "path/to/file.pdf"}'The application uses config/config.json for storing printer configurations. The file is automatically created if it doesn't exist.
go-printer/
├── cmd/server/ # Main application entry point
├── internal/
│ ├── app/ # Application setup and initialization
│ ├── handlers/ # HTTP request handlers
│ ├── services/ # Business logic services
│ ├── routers/ # Route definitions
│ ├── dto/ # Data transfer objects
│ └── utils/ # Utility functions
├── config/ # Configuration files
├── uploads/ # Uploaded files directory
├── docs/ # Documentation
├── build/ # Build artifacts
└── README.md
- Gin - HTTP web framework
- gin-contrib/cors - CORS middleware
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.