From: Rob Pike Date: Thu, 16 Feb 2012 02:12:42 +0000 (-0800) Subject: cmd/go: fix 'go help' X-Git-Tag: weekly.2012-02-22~207 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d3f9aa47e5bc8e95234279d8b0aed6f54bb98d81;p=gostls13.git 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 --- diff --git a/src/cmd/go/main.go b/src/cmd/go/main.go index 44f33d4f00..c688a739d0 100644 --- a/src/cmd/go/main.go +++ b/src/cmd/go/main.go @@ -64,6 +64,12 @@ func (c *Command) Usage() { 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. // The order here is the order in which they are printed by 'go help'. var commands = []*Command{ @@ -138,13 +144,13 @@ var usageTemplate = `Go is a tool for managing Go source code. Usage: go command [arguments] The commands are: -{{range .}}{{if .Run}} +{{range .}}{{if .Runnable}} {{.Name | printf "%-11s"}} {{.Short}}{{end}}{{end}} Use "go help [command]" for more information about a command. Additional help topics: -{{range .}}{{if not .Run}} +{{range .}}{{if not .Runnable}} {{.Name | printf "%-11s"}} {{.Short}}{{end}}{{end}} Use "go help [topic]" for more information about that topic.