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/m
with your own package name. - The default is
example.com/m
You 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/greet
tocmd/YOUR_APP_NAME
- Rename inside
Makefile
forBIN_NAMES
- Rename inside
conf/*.toml
for logger file name - Rename inside
cmd/greet/app/conf.go
forName
constasnt - Rename insdie
.vscode
for debugging
- The default application name is
-
Add more application if needed
- Add more application in
cmd
folder just likegreet
app. - Add more application name in
Makefile
forBIN_NAMES
, for example:
BIN_NAMES=app1 app2
- Add more application in
-
Enable write permission for workflow
- Click
Settings
tab of your repository. - Select
Action -> General
in left sidebar. - Locate
Workflow permissions
section. - Check
Read and write permission
- Click
- Edit
README.md
. SwitchLICENSE
to your own license. - Coding for your application.
- Run
make dev
to build for your local machine. - Run
make test
to run unit tests. - Run
make package
to cross compile for different platforms. - Click
Action
tab of your repository to see the Github Action workflow. In release workflow, clickRun workflow
button 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
--verbose
and--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