Commit d595b67a authored by Rob Pike's avatar Rob Pike

cmd/go: add -race flag to 'go list'

Causes the package dependencies to include those for race detection.
Fixes #5653.

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/13236045
parent 1d7699e9
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
) )
var cmdList = &Command{ var cmdList = &Command{
UsageLine: "list [-e] [-f format] [-json] [-tags 'tag list'] [packages]", UsageLine: "list [-e] [-race] [-f format] [-json] [-tags 'tag list'] [packages]",
Short: "list packages", Short: "list packages",
Long: ` Long: `
List lists the packages named by the import paths, one per line. List lists the packages named by the import paths, one per line.
...@@ -91,6 +91,9 @@ a non-nil Error field; other information may or may not be missing ...@@ -91,6 +91,9 @@ a non-nil Error field; other information may or may not be missing
The -tags flag specifies a list of build tags, like in the 'go build' The -tags flag specifies a list of build tags, like in the 'go build'
command. command.
The -race flag causes the package data to include the dependencies
required by the race detector.
For more about specifying packages, see 'go help packages'. For more about specifying packages, see 'go help packages'.
`, `,
} }
...@@ -104,12 +107,17 @@ func init() { ...@@ -104,12 +107,17 @@ func init() {
var listE = cmdList.Flag.Bool("e", false, "") var listE = cmdList.Flag.Bool("e", false, "")
var listFmt = cmdList.Flag.String("f", "{{.ImportPath}}", "") var listFmt = cmdList.Flag.String("f", "{{.ImportPath}}", "")
var listJson = cmdList.Flag.Bool("json", false, "") var listJson = cmdList.Flag.Bool("json", false, "")
var listRace = cmdList.Flag.Bool("race", false, "")
var nl = []byte{'\n'} var nl = []byte{'\n'}
func runList(cmd *Command, args []string) { func runList(cmd *Command, args []string) {
out := newTrackingWriter(os.Stdout) out := newTrackingWriter(os.Stdout)
defer out.w.Flush() defer out.w.Flush()
if *listRace {
buildRace = true
}
var do func(*Package) var do func(*Package)
if *listJson { if *listJson {
do = func(p *Package) { do = func(p *Package) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment