A powerful Golang CLI application scaffold integrated with logrus, go-arg, config, testify and Github Action.
Click Use this template button to create a new repository. Then clone the new repository to your local machine.
-
Change the package name
- Replace
example.com/mwith your own package name. - The default is
example.com/mYou can replace bysed:
sed -i 's/example.com\/m/your.package.name/g' $(find . -type f)
Or use global search and replace in your IDE.
- Replace
-
Change the module name
- The default application name is
greet - Rename
cmd/greettocmd/YOUR_APP_NAME - Rename inside
MakefileforBIN_NAMES - Rename inside
conf/*.tomlfor logger file name - Rename inside
cmd/greet/app/conf.goforNameconstasnt - Rename insdie
.vscodefor debugging
- The default application name is
-
Add more application if needed
- Add more application in
cmdfolder just likegreetapp. - Add more application name in
MakefileforBIN_NAMES, for example:
BIN_NAMES=app1 app2 - Add more application in
-
Enable write permission for workflow
- Click
Settingstab of your repository. - Select
Action -> Generalin left sidebar. - Locate
Workflow permissionssection. - Check
Read and write permission
- Click
- Edit
README.md. SwitchLICENSEto your own license. - Coding for your application.
- Run
make devto build for your local machine. - Run
make testto run unit tests. - Run
make packageto cross compile for different platforms. - Click
Actiontab of your repository to see the Github Action workflow. In release workflow, clickRun workflowbutton to release your application.
go run cmd/greet/main.go Jack -v -c ./dist/config.example.toml- Logrus logger. JSON format
- Multiple logging output: file, stdout, stderr
- Command line args, such as
--verboseand--config - Config file, such as
./dist/config.example.toml - Find config file in current directory and home directory (~/.config/APP_NAME/config.toml)
- Log rotation
Use | jq to pretty print JSON log.
Generate structs for your config file: Toml to Go