mirror of
https://github.com/golang/go
synced 2024-11-19 23:34:40 -07:00
cmd/go: fix 'go help'
It depended on old behavior of functions in structs. Solved by adding a boolean method to check .Run != nil. R=golang-dev, adg, r, rsc CC=golang-dev https://golang.org/cl/5674062
This commit is contained in:
parent
e9016bb8a7
commit
d3f9aa47e5
@ -64,6 +64,12 @@ func (c *Command) Usage() {
|
|||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Runnable reports whether the command can be run; otherwise
|
||||||
|
// it is a documentation pseudo-command such as importpath.
|
||||||
|
func (c *Command) Runnable() bool {
|
||||||
|
return c.Run != nil
|
||||||
|
}
|
||||||
|
|
||||||
// Commands lists the available commands and help topics.
|
// Commands lists the available commands and help topics.
|
||||||
// The order here is the order in which they are printed by 'go help'.
|
// The order here is the order in which they are printed by 'go help'.
|
||||||
var commands = []*Command{
|
var commands = []*Command{
|
||||||
@ -138,13 +144,13 @@ var usageTemplate = `Go is a tool for managing Go source code.
|
|||||||
Usage: go command [arguments]
|
Usage: go command [arguments]
|
||||||
|
|
||||||
The commands are:
|
The commands are:
|
||||||
{{range .}}{{if .Run}}
|
{{range .}}{{if .Runnable}}
|
||||||
{{.Name | printf "%-11s"}} {{.Short}}{{end}}{{end}}
|
{{.Name | printf "%-11s"}} {{.Short}}{{end}}{{end}}
|
||||||
|
|
||||||
Use "go help [command]" for more information about a command.
|
Use "go help [command]" for more information about a command.
|
||||||
|
|
||||||
Additional help topics:
|
Additional help topics:
|
||||||
{{range .}}{{if not .Run}}
|
{{range .}}{{if not .Runnable}}
|
||||||
{{.Name | printf "%-11s"}} {{.Short}}{{end}}{{end}}
|
{{.Name | printf "%-11s"}} {{.Short}}{{end}}{{end}}
|
||||||
|
|
||||||
Use "go help [topic]" for more information about that topic.
|
Use "go help [topic]" for more information about that topic.
|
||||||
|
Loading…
Reference in New Issue
Block a user