github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/simplecode/gotool/tool.go (about) 1 // Package gotool contains utility functions used to implement the standard 2 // "cmd/go" tool, provided as a convenience to developers who want to write 3 // tools with similar semantics. 4 package gotool 5 6 import "go/build" 7 8 // Export functions here to make it easier to keep the implementations up to date with upstream. 9 10 // DefaultContext is the default context that uses build.Default. 11 var DefaultContext = Context{ 12 BuildContext: build.Default, 13 } 14 15 // A Context specifies the supporting context. 16 type Context struct { 17 // BuildContext is the build.Context that is used when computing import paths. 18 BuildContext build.Context 19 } 20 21 // ImportPaths returns the import paths to use for the given command line. 22 // 23 // The path "all" is expanded to all packages in $GOPATH and $GOROOT. 24 // The path "std" is expanded to all packages in the Go standard library. 25 // The path "cmd" is expanded to all Go standard commands. 26 // The string "..." is treated as a wildcard within a path. 27 // When matching recursively, directories are ignored if they are prefixed with 28 // a dot or an underscore (such as ".foo" or "_foo"), or are named "testdata". 29 // Relative import paths are not converted to full import paths. 30 // If args is empty, a single element "." is returned. 31 func (c *Context) ImportPaths(args []string) []string { 32 return c.importPaths(args) 33 } 34 35 // ImportPaths returns the import paths to use for the given command line 36 // using default context. 37 // 38 // The path "all" is expanded to all packages in $GOPATH and $GOROOT. 39 // The path "std" is expanded to all packages in the Go standard library. 40 // The path "cmd" is expanded to all Go standard commands. 41 // The string "..." is treated as a wildcard within a path. 42 // When matching recursively, directories are ignored if they are prefixed with 43 // a dot or an underscore (such as ".foo" or "_foo"), or are named "testdata". 44 // Relative import paths are not converted to full import paths. 45 // If args is empty, a single element "." is returned. 46 func ImportPaths(args []string) []string { 47 return DefaultContext.importPaths(args) 48 }