Skip to content

Instantly share code, notes, and snippets.

@adamluzsi
Created April 25, 2018 11:17
Show Gist options
  • Save adamluzsi/136c78a989daf69a18a61f8367151cd4 to your computer and use it in GitHub Desktop.
Save adamluzsi/136c78a989daf69a18a61f8367151cd4 to your computer and use it in GitHub Desktop.
golang flag how to create aliases for set flags such as short versions
package main
var flagAlias = map[string]string{
"long-version": "lv",
}
func init() {
for from, to := range flagAlias {
flagSet := flag.Lookup(from)
cli.Var(flagSet.Value, to, fmt.Sprintf("alias to %s", flagSet.Name))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment