2. Why Golang for CLI?
● Cross Platform Compilation. (Windows, Linux, Mac, BSD, Solaris)
● Dependencies can be statically linked & packaged into single binary.
● Execution performance is close to C/C++.
● Popular CLI Apps in Golang:
○ Packer
○ Terraform
○ Consul
○ Kubernetes
○ Prometheus
○ Docker
○ Hugo
○ etcd
3. CLI Structure
● Appname: Name of App
● Subcommand: Represents
action
● Flags: Modifiers for action
● Arguments: Input on which
actions will be applied.
Example:
4. Why CLI Framework?
● Provides libs/functions/boilerplate for following:
○ Subcommands and nested subcommands. (e.g. git clone/pull/push)
○ POSIX compliant flags. (e.g. git clone -q/--quiet)
○ Ability to generate help documentation from the comments. (e.g. git clone/pull --
help)
○ Ability to generate man pages. (man git)
○ Ability to generate bash autocomplete. (/etc/bash_completion.d/)
○ Intelligent suggestions. (git clne → Did you mean this ? → git clone)
○ Provide inline and configuration file support. ($HOME/.app.yaml)