🚀🚀🚀 Start a web project right away using gonic-gin/gin and other practical tools!!! 🚀🚀🚀
Use this framework to easily launch a Golang web service with the following features:
- gingonic/gin web engine & graceful shutdown
- log system with rotation func by gin-melodic/glog
- configuration parsing func by spf13/viper
- Install golang and configure golang environment.
- Create a project folder by
mkdir myApp
cd myApp
In your project root directory and run:
wget https://raw.githubusercontent.com/gin-melodic/gboot/main/install.sh && bash install.sh && rm install.sh
Since the script needs to be an interactive shell, it cannot be executed using the previous wget -qO- with pipeline
The script will provide options that dynamically affect the code that creates the item.
These options are:
project name
Get the name of the current folder as the project name by default.author name
The default value anonymous is actually meaningless and is highly recommended to be changed. One suggestion is to use your github username, which together withproject name
will form project address on github likehttps://github.com/<author>/<project>
.use one-click installation
If this option is Y, then all subsequent questions will be skipped and the created project will use 8000 as the listening port, './log/' as the directory for the log files, the log file rotation is set to 7 days, and the script will generate sample code for connecting to the database.project port
Set the service listening port in the configuration file.log save path
Set the log files saving path in the configuration file.log overwrite days
Set the log file rotation time in the configuration file.database demo code
If this option is Y, the script will generate sample code for connecting to the database. It's worth noting that the generated database connection initialisation code uses a glogger I wrote as the SQL execution print handle, which is particularly nice to have when Debugging.
In addition to the service code itself, the script generates a powerful Makefile for compiling and packaging the service. You can add more customisation to this makefile.