mirror of
https://github.com/golang/go
synced 2024-11-12 02:40:21 -07:00
go: fix help text documenting example functions
R=adg, r CC=golang-dev https://golang.org/cl/5695062
This commit is contained in:
parent
e303eeb75b
commit
5c7799f108
@ -76,7 +76,7 @@ flags are also accessible by 'go test'. See 'go help testflag' for details.
|
|||||||
See 'go help importpath' for more about import paths.
|
See 'go help importpath' for more about import paths.
|
||||||
|
|
||||||
See also: go build, go vet.
|
See also: go build, go vet.
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
var helpTestflag = &Command{
|
var helpTestflag = &Command{
|
||||||
@ -146,7 +146,7 @@ here are passed through unaltered. For instance, the command
|
|||||||
will compile the test binary and then run it as
|
will compile the test binary and then run it as
|
||||||
|
|
||||||
pkg.test -test.v -test.cpuprofile=prof.out -dir=testdata -update
|
pkg.test -test.v -test.cpuprofile=prof.out -dir=testdata -update
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
var helpTestfunc = &Command{
|
var helpTestfunc = &Command{
|
||||||
@ -167,8 +167,10 @@ A benchmark function is one named BenchmarkXXX and should have the signature,
|
|||||||
|
|
||||||
An example function is similar to a test function but, instead of using *testing.T
|
An example function is similar to a test function but, instead of using *testing.T
|
||||||
to report success or failure, prints output to os.Stdout and os.Stderr.
|
to report success or failure, prints output to os.Stdout and os.Stderr.
|
||||||
That output is compared against the function's doc comment.
|
That output is compared against the function's "Output:" comment, which
|
||||||
An example without a doc comment is compiled but not executed.
|
must be the last comment in the function body (see example below). An
|
||||||
|
example with no such comment, or with no text after "Output:" is compiled
|
||||||
|
but not executed.
|
||||||
|
|
||||||
Godoc displays the body of ExampleXXX to demonstrate the use
|
Godoc displays the body of ExampleXXX to demonstrate the use
|
||||||
of the function, constant, or variable XXX. An example of a method M with
|
of the function, constant, or variable XXX. An example of a method M with
|
||||||
@ -179,8 +181,9 @@ where xxx is a suffix not beginning with an upper case letter.
|
|||||||
Here is an example of an example:
|
Here is an example of an example:
|
||||||
|
|
||||||
func ExamplePrintln() {
|
func ExamplePrintln() {
|
||||||
Println("The output of this example function.")
|
Println("The output of\nthis example.")
|
||||||
// Output: The output of this example function.
|
// Output: The output of
|
||||||
|
// this example.
|
||||||
}
|
}
|
||||||
|
|
||||||
The entire test file is presented as the example when it contains a single
|
The entire test file is presented as the example when it contains a single
|
||||||
@ -188,7 +191,7 @@ example function, at least one other function, type, variable, or constant
|
|||||||
declaration, and no test or benchmark functions.
|
declaration, and no test or benchmark functions.
|
||||||
|
|
||||||
See the documentation of the testing package for more information.
|
See the documentation of the testing package for more information.
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user