This is a quick and simple example of a Go CLI application. The Cobra library is used to handle argument and flag parsing.
Execute go-template-cli help
for more detailed information.
Command | Arguments | Description |
---|---|---|
subcommand | [flags] <input-text> |
Example argument handling |
> go build
Using the Delve debugger with CLI applications is a little tricky. See the Delve documentation for recommended procedures on how to do this.
While the produced binary is a CLI application and is intended to be executed by directly, a containerized installation is also provided. This container utilizes a dedicated build stage along with the scratch Docker image to ensure the final image contains only the necessary resources and nothing else.
> docker build . -t go-template-cli
> docker run go-template-cli subcommand "Hello, World!"
This example code is provided to the public domain via the CC0 1.0 Universal License. See LICENSE.md for more information.