golang-starter
is a boilerplate project for starting new Go projects. It includes a basic setup for a web server, database migrations, and testing. The project uses Docker for containerization and includes a Makefile for common tasks.
- Docker
- Docker Compose
- Go
-
Start the project:
make up
This command will start the Docker containers for the project.
-
Access the server:
Open your browser and navigate to
http://localhost:8080
. Swagger documentation is available athttp://localhost:8080/swagger
. -
Open a container bash window:
make bash
To stop the running containers:
make stop
To remove the containers and associated volumes:
make down
To run the tests:
make tests
To run the database migrations:
make migrate
To create a new migration file:
make migration
You will be prompted to enter a migration name. This will create new .up.sql
and .down.sql
files in the internal/migrations
directory.
To view the logs:
make logs
cmd
: Contains the main entry point for the application.internal
: Contains the core application code.app/
: Wire up use cases.config/
: Configuration handling.container/
: Dependency injection container.http/
: HTTP server and routing.log/
: Logging setup.migrations/
: Database migration files.todo/
: Example feature module.
pkg
: Contains reusable packages.middleware/
: HTTP middleware.mysql/
: MySQL database utilities.validator/
: Request validation.
docs
: API documentation..github/workflows
: GitHub Actions workflows for CI/CD.
Configuration is managed using the config.yml
file. Environment variables can override the configuration values. The environment variables should be prefixed with MYVAR_
and use _
as the delimiter.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.