From 08ba9c02910790c5ec9083dc32a1e2683bc77dc3 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Thu, 15 Nov 2018 23:35:27 +0530 Subject: [PATCH] cmd/go/internal/{run,work,generate}: document file path location requirement Mention that .go files must be from a single directory for them to be treated as a single package. Fixes #21529 Change-Id: I79cb08b9f43888814b1249a7b50bc7bc70bc1c72 Reviewed-on: https://go-review.googlesource.com/c/go/+/149797 Reviewed-by: Dmitri Shuralyov --- src/cmd/go/alldocs.go | 10 +++++----- src/cmd/go/internal/generate/generate.go | 4 ++-- src/cmd/go/internal/run/run.go | 2 +- src/cmd/go/internal/work/build.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 5b62ed939c..8dd3f8eb18 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -74,8 +74,8 @@ // Build compiles the packages named by the import paths, // along with their dependencies, but it does not install the results. // -// If the arguments to build are a list of .go files, build treats -// them as a list of source files specifying a single package. +// If the arguments to build are a list of .go files from a single directory, +// build treats them as a list of source files specifying a single package. // // When compiling a single main package, build writes // the resulting executable to an output file named after @@ -505,8 +505,8 @@ // "go tool foo". // // Generate processes packages in the order given on the command line, -// one at a time. If the command line lists .go files, they are treated -// as a single package. Within a package, generate processes the +// one at a time. If the command line lists .go files from a single directory, +// they are treated as a single package. Within a package, generate processes the // source files in a package in file name order, one at a time. Within // a source file, generate runs generators in the order they appear // in the file, one at a time. @@ -1170,7 +1170,7 @@ // go run [build flags] [-exec xprog] package [arguments...] // // Run compiles and runs the named main Go package. -// Typically the package is specified as a list of .go source files, +// Typically the package is specified as a list of .go source files from a single directory, // but it may also be an import path, file system path, or pattern // matching a single known package, as in 'go run .' or 'go run my/cmd'. // diff --git a/src/cmd/go/internal/generate/generate.go b/src/cmd/go/internal/generate/generate.go index 23e2ecc224..38c8274b40 100644 --- a/src/cmd/go/internal/generate/generate.go +++ b/src/cmd/go/internal/generate/generate.go @@ -110,8 +110,8 @@ specifies that the command "foo" represents the generator "go tool foo". Generate processes packages in the order given on the command line, -one at a time. If the command line lists .go files, they are treated -as a single package. Within a package, generate processes the +one at a time. If the command line lists .go files from a single directory, +they are treated as a single package. Within a package, generate processes the source files in a package in file name order, one at a time. Within a source file, generate runs generators in the order they appear in the file, one at a time. diff --git a/src/cmd/go/internal/run/run.go b/src/cmd/go/internal/run/run.go index feccf23b27..8b3006bf2c 100644 --- a/src/cmd/go/internal/run/run.go +++ b/src/cmd/go/internal/run/run.go @@ -22,7 +22,7 @@ var CmdRun = &base.Command{ Short: "compile and run Go program", Long: ` Run compiles and runs the named main Go package. -Typically the package is specified as a list of .go source files, +Typically the package is specified as a list of .go source files from a single directory, but it may also be an import path, file system path, or pattern matching a single known package, as in 'go run .' or 'go run my/cmd'. diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index eac027e09e..96b3744444 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -27,8 +27,8 @@ var CmdBuild = &base.Command{ Build compiles the packages named by the import paths, along with their dependencies, but it does not install the results. -If the arguments to build are a list of .go files, build treats -them as a list of source files specifying a single package. +If the arguments to build are a list of .go files from a single directory, +build treats them as a list of source files specifying a single package. When compiling a single main package, build writes the resulting executable to an output file named after -- 2.50.0