main
API
main
packageAPI reference for the main
package.
S
struct
Options
examples/basic/main.go:11-14
type Options struct
Fields
| Name | Type | Description |
|---|---|---|
| Verbose | bool | flag:"short:v, long:verbose, name:Enable Verbose Output" |
| Output | string | flag:"short:o, long:output, default:json" |
F
function
main
examples/basic/main.go:16-33
func main()
{
opts := &Options{}
// Bind flags to the struct
structflags.Bind(opts)
// Parse standard flags
flag.Parse()
if len(os.Args) == 1 {
fmt.Println("Usage: example [flags]")
flag.PrintDefaults()
return
}
fmt.Printf("Verbose: %v\n", opts.Verbose)
fmt.Printf("Output: %v\n", opts.Output)
}