This is a starter template for using Go as a REST service. It uses Fiber as the web framework and GORM as the ORM.
Because Go is awesome. And will serve more requests per dollar than most other languages.
- A Makefile with commands for running the application in development and production mode, building the application, running tests and running database migrations
- Swagger documentation for the API
- Project structure for a web application
- Web framework and ORM setup
- swag: To generate OpenAPI documentation using
make docs
you need to install swag system-wide. Installation is detailed in their Github. - Go: duh
After cloning this template repository & adding database credentials in a .env
file in the root directory, the following Makefile commands are available:
make dev
- Runs the application in development modemake build
- Builds the applicationmake prod
- Runs the application in production mode. This requires the application to be built firstmake test
- Runs any Go test it findsmake migrate-db
- Runs the database migrationsmake docs
- Generates/Updates the OpenAPI documentation. Check the Note section for more details.
log-sql
- Runs the server with logging for every query generated by Gormmigrate
- Migrates the database instead of running
Generation OpenAPI documentation is seamless. However, for some reason with the technologies that I am using to generate and view the /swagger/index.html/ page there seems to be caching issues where Newly generated documents are not shown in the browser. If you ever encounter an issue with the content not being updated after running make docs
just clear the cache or view the page from another browser window (anonymous window is optimal.)
Feel free to open issues and pull requests. Any feedback is welcome!
This project is licensed under the Unlicensed License - see the UNLICENSE file for details