☄️ Powerful template for Go CLI projects with advanced config management
Powerful template for Go CLI applications with advanced config management
Advanced config management with viper and
useful config commands such as setting config values directly from CLI (like this config set -k logs.write -v true
),
reading env variables and file-based configuration (either TOML or YAML). Also, configuration is self-documented, type config info
to show every config field available with description for each.
Cache & Temp files management with clear
command
Polished CLI experience with cobra + coloredcobra to make things look pretty
Afero filesystem for various fs utils, abstractions and in-memory fs for testing.
For example, instead of os.Remove("file")
use filesystem.Api().Remove("file")
Easy to use path management with where
package
Logging to file
Icons!
Predefined lipgloss colors
Press this shiny green button on top
Then you would probably want to rename go mod name from github.com/metafates/go-template
to something else.
To do this you could use your IDE refactor features or run just target.
just rename github.com/username/repo
This will prompt you to type a new name and will replace every occurence of the old go mod name with the new one.
Change the value of the constant Name
at app/meta.go
Change the value of the constant ConfigFormat
at config/init.go
Firstly, declare a field key name as a constant inside key/keys.go
Then put them inside config/default.go (take a predefined fields for logging as a reference)
For example
// key/keys.go
const IconType = "icon.type"
// config/default.go
{
constant.IconType, // config field key
"emoji", // default value
"What type of icons to use", // description
}
For the example above it would be viper.GetString(key.EmojiType)
. See viper for more information
Please, open an issue so I could document it