This template provides a starter kit for building a command-line interface (CLI) application in Go using the popular Cobra library.
When you create a project from this template, the Go module path will be automatically set to the value you provided.
- Structure: Follows the standard Cobra layout (
main.goand acmd/directory). - Example Command: Includes a
hellosubcommand to demonstrate basic functionality. - Flag Support: The
hellocommand includes a--nameflag to show how to handle user input.
-
Build the binary:
go build -o my-cli . -
Run the command:
# Run the default hello command ./my-cli hello # Run with the name flag ./my-cli hello --name "Alice"