Documentation
¶
Overview ¶
Package gocli implements common idioms for handling Go packages in command line programs.
Index ¶
- func FirstError(pkgs []goutil.Packages, errs []error) ([]goutil.Packages, error)
- func Flatten(pss []goutil.Packages) (out goutil.Packages)
- func Import(notree bool, ctx *build.Context, args []string) (pkgs []goutil.Packages, errs []error)
- func ImportOne(notree bool, ctx *build.Context, args []string) (goutil.Packages, error)
- func TagsFlag(tags string) *[]string
- func TagsFlagSet(f *flag.FlagSet, tags string) *[]string
- func TagsFlagSetVar(f *flag.FlagSet, val *[]string, tags string)
- func TagsFlagVar(val *[]string, tags string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstError ¶
FirstError is meant to wrap Import, it returns pkgs unchanged. If there were errors, only the first is returned.
func Flatten ¶
Flatten takes a slice of goutil.Packages and returns a single goutil.Packages containing only the unique packages from the slice.
func Import ¶
Import is for importing command line arguments. It uses the following rules:
If args is len 0, try to import the current directory. Otherwise, for each argument: If it ends with ..., use goutil.ImportTree (unless notree is true) Otherwise, use goutil.Import
Regardless, the ctx is passed as is to the various importers.
Import returns a list of any errors that resulted from attmepting to import. If you only care about the first error, wrap the call in FirstError.
func TagsFlag ¶
TagsFlag defines a tags flag, matching the tags flag on the go tool. The returned value is the address of a []string variable that stores the value of that flag.
The tags flag behaves exactly like the -tag flag for the go tool.
The name of the flag is always tags. The usage string is set to one similar to the usage of the tags flag on the go tool.
func TagsFlagSet ¶
TagsFlagSet defines a tags flag, matching the tags flag on the go tool. The returned value is the address of a []string variable that stores the value of that flag.
The tags flag behaves exactly like the -tag flag for the go tool.
The name of the flag is always tags. The usage string is set to one similar to the usage of the tags flag on the go tool.
func TagsFlagSetVar ¶
TagsFlagSetVar defines a tags flag, matching the tags flag on the go tool.
The tags flag behaves exactly like the -tag flag for the go tool.
The name of the flag is always tags. The usage string is set to one similar to the usage of the tags flag on the go tool.
func TagsFlagVar ¶
TagsFlagVar defines a tags flag, matching the tags flag on the go tool.
The tags flag behaves exactly like the -tag flag for the go tool.
The name of the flag is always tags. The usage string is set to one similar to the usage of the tags flag on the go tool.
Types ¶
This section is empty.