A template for building web services in Go using Fiber, Wire, and other common libraries.
- Fiber: An Express inspired web framework built on Fasthttp.
- Wire: A code generation tool for dependency injection.
- Zap logger: A blazing fast, structured, leveled logger.
- Viper config: A complete configuration solution for Go applications.
- JWT: JSON Web Tokens for authentication.
- Cron jobs: Scheduled task execution.
- ozzo-dbx: A powerful data access layer for Go.
- Redis: In-memory data structure store, used as a cache or message broker.
- Go 1.21 or higher
git clone https://github.com/your-username/your-repository.git
cd your-repository
This project uses Viper for configuration management. You can set the APP_CONF
environment variable to specify which configuration file to use. For example:
export APP_CONF=local # Uses config/local.yaml
# or
export APP_CONF=prod # Uses config/prod.yaml
If APP_CONF
is not set, it defaults to local
.
go mod tidy
go run cmd/app/main.go
Configuration files are located in the config/
directory.
config/local.yaml
: Configuration for local development.config/prod.yaml
: Configuration for production.
The APP_CONF
environment variable determines which configuration file is loaded. See the "Set up environment variables" section for more details.
cmd/
: Main applications for the project.cmd/app/main.go
: The entry point for the web service.
internal/
: Private application and library code. This is where the core business logic resides.internal/bootstrap
: Application initialization (config, logger, database, etc.).internal/controller
: HTTP handlers.internal/core
: Core business logic and services.internal/middleware
: HTTP request middleware.internal/model
: Data structures and database models.internal/repository
: Data access layer.
pkg/
: Library code that's safe to use by external applications.config/
: Configuration files.route/
: API route definitions.
Specific API endpoints should be documented here. Include information such as:
- HTTP Method (GET, POST, PUT, DELETE, etc.)
- URL Path
- Request Parameters (if any)
- Request Body (if any)
- Success Response (status code, body)
- Error Responses (status codes, body)
Contributions are welcome! Please feel free to submit a pull request.
Standard placeholder text:
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature
). - Commit your changes (
git commit -m 'Add some AmazingFeature'
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a pull request.
This project is licensed under the MIT License.