This is a template repository to create CLI using golang. It creates a powerful cli using Cobra and Viper as main packages.
Create your own .config.yaml
file to configure the CLI.
To set up the git hooks run the following command.
cp ./scripts/pre-commit-hook.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
go run ./cmd/golang-cli/main.go help
This package uses go modules. Whenever you run go build
or go test
all dependencies will be downloaded automatically. See go.mod and go.sum to see all modules used by this package.
Many settings are set throught the .config.yaml
file and read using the Viper package to set the configuration of the project and to retrieve the configuration values.
An example of the configuration file can be found at configs/.config.example.yaml
.
The project structure used follows the project layout defined in Golang Standards - Project Layout, which used a lot of definitions found in the web and compiled an unified layout.