Skip to content

Commit 945ab1b

Browse files
authored
Update documentation examples to use 'Example' instead of 'Test' functions (#806)
* Update documentation examples to use "Example" instead of "Test" functions * Update integers.md
1 parent d9f03be commit 945ab1b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

integers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ If you really want to go the extra mile you can make [Testable Examples](https:/
120120

121121
Often code examples that can be found outside the codebase, such as a readme file become out of date and incorrect compared to the actual code because they don't get checked.
122122

123-
Testable Examples are compiled whenever tests are executed. Because such examples are validated by the Go compiler, you can be confident your documentation's examples always reflect current code behavior.
123+
Example functions are compiled whenever tests are executed. Because such examples are validated by the Go compiler, you can be confident your documentation's examples always reflect current code behavior.
124124

125-
Testable functions begin with `Example` (much like test functions begin with `Test`), and reside in a package's `_test.go` files, . Add the following `ExampleAdd` function to the `adder_test.go` file.
125+
Example functions begin with `Example` (much like test functions begin with `Test`), and reside in a package's `_test.go` files, . Add the following `ExampleAdd` function to the `adder_test.go` file.
126126

127127
```go
128128
func ExampleAdd() {
@@ -134,7 +134,7 @@ func ExampleAdd() {
134134

135135
(If your editor doesn't automatically import packages for you, the compilation step will fail because you will be missing `import "fmt"` in `adder_test.go`. It is strongly recommended you research how to have these kind of errors fixed for you automatically in whatever editor you are using.)
136136

137-
Adding this code will cause the example to appear in your `godoc` documentation, making your code even more accessible. If ever your code changes so that the example is no longer valid, your build will fail.
137+
Adding this code will cause the example to appear in your `godoc` documentation, making your code even more accessible. If ever your code changes so that the example is no longer valid, your build will fail.
138138

139139
Running the package's test suite, we can see the example `ExampleAdd` function is executed with no further arrangement from us:
140140

0 commit comments

Comments
 (0)