Skip to content

a simple Go CLI (Command Line Interface) template that you can use as a starting point for building your own command-line applications in Go.

License

Notifications You must be signed in to change notification settings

emmanuelgautier/go-cli-template

Repository files navigation

Go CLI Template

CI Tasks for Go Cli template Go Report Card PkgGoDev

This is a simple Go CLI (Command Line Interface) template that you can use as a starting point for building your own command-line applications in Go. It provides a basic structure and some common features to help you get started quickly.

Features

  • Command-line argument parsing using the cobra package.
  • Simple subcommand support.
  • Github Actions workflow
  • GoReleaser preconfigured for Docker build, Github Release binaries (multi-archi) builds and snapcraft publishing.

Usage

  1. Clone or download this repository:
git clone https://github.com/emmanuelgautier/go-cli-template.git
cd go-cli-template
  1. Build the CLI tool:
go build -o go-cli-template
  1. Run the CLI tool with the --help flag to see the available commands:
./go-cli-template --help

You should see output similar to the following:

A simple Go CLI template.

Usage:
  go-cli-template [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  hello       Prints a friendly greeting
  help        Help about any command

Flags:
  -h, --help   help for go-cli-template

Use "go-cli-template [command] --help" for more information about a command.
  1. Run the hello subcommand:
./go-cli-template hello --name YourName

Replace YourName with your actual name. This command will print a greeting.

License

This Go CLI template is open-source and available under the MIT License. Feel free to use it as a starting point for your own CLI applications. Contributions and improvements are welcome!

Author

Emmanuel Gautier