147
fmt.Fprintf(os.Stderr, "Unknown command %#q\n\n", args[0])
147
fmt.Fprintf(os.Stderr, "go: unknown subcommand %q\nRun 'go help' for usage.\n", args[0])
151
152
var usageTemplate = `Go is a tool for managing Go source code.
340
341
func run(cmdargs ...interface{}) {
341
342
cmdline := stringList(cmdargs...)
343
if buildN || buildV {
344
fmt.Printf("%s\n", strings.Join(cmdline, " "))
342
350
cmd := exec.Command(cmdline[0], cmdline[1:]...)
343
351
cmd.Stdout = os.Stdout
344
352
cmd.Stderr = os.Stderr
501
509
var pkgs []string
502
510
filepath.Walk(dir, func(path string, fi os.FileInfo, err error) error {
503
if err != nil || !fi.IsDir() || path == dir {
511
if err != nil || !fi.IsDir() {
515
// filepath.Walk starts at dir and recurses. For the recursive case,
516
// the path is the result of filepath.Join, which calls filepath.Clean.
517
// The initial case is not Cleaned, though, so we do this explicitly.
519
// This converts a path like "./io/" to "io". Without this step, running
520
// "cd $GOROOT/src/pkg; go list ./io/..." would incorrectly skip the io
521
// package, because prepending the prefix "./" to the unclean path would
522
// result in "././io", and match("././io") returns false.
523
path = filepath.Clean(path)
507
// Avoid .foo, _foo, and testdata directory trees.
526
// Avoid .foo, _foo, and testdata directory trees, but do not avoid "." or "..".
508
527
_, elem := filepath.Split(path)
509
if strings.HasPrefix(elem, ".") || strings.HasPrefix(elem, "_") || elem == "testdata" {
528
dot := strings.HasPrefix(elem, ".") && elem != "." && elem != ".."
529
if dot || strings.HasPrefix(elem, "_") || elem == "testdata" {
510
530
return filepath.SkipDir