-
Notifications
You must be signed in to change notification settings - Fork 29
/
doc_test.go
54 lines (45 loc) · 1.43 KB
/
doc_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package godoctricks
import (
"fmt"
)
// This function is named Example(), which is a package level test
// function.
func Example() {
fmt.Println("Hello")
}
// This function is named Example_other(), which is a package level test
// function and has the label "other".
func Example_other() {
fmt.Println("Hello")
}
// This function is named ExampleExamples(), this way godoc knows to associate
// it with the Examples type.
func ExampleExamples() {
fmt.Println("Hello")
}
// This function is named ExampleExamples_other(), it is associated with
// Examples type and has the label "Other".
func ExampleExamples_other() {
fmt.Println("Hello")
}
// This is how godoc parsed ExampleExamples_output() that was shown above.
func ExampleExamples_output() {
fmt.Println("Hello")
// Output: Hello
}
// This function is named ExampleNewExamples(), this way godoc knows to associate
// it with the NewExamples func.
func ExampleNewExamples() {
fmt.Println("Hello", NewExamples())
}
// This function is named ExampleExamples_ExampleMethod(), this way godoc knows to associate
// it with the ExampleMethod method of the Examples type.
func ExampleExamples_ExampleMethod() {
e := Examples(42)
fmt.Println("Hello", e.ExampleMethod())
}
// This function is named ExampleFuncExampleWithoutType(), this way godoc knows to associate
// it with the FuncExampleWithoutType func.
func ExampleFuncExampleWithoutType() {
fmt.Println("Hello", FuncExampleWithoutType())
}