aboutsummaryrefslogtreecommitdiff
path: root/_content/doc/tutorial
diff options
context:
space:
mode:
Diffstat (limited to '_content/doc/tutorial')
-rw-r--r--_content/doc/tutorial/fuzz.md37
1 files changed, 33 insertions, 4 deletions
diff --git a/_content/doc/tutorial/fuzz.md b/_content/doc/tutorial/fuzz.md
index 40575f90..0f96ce52 100644
--- a/_content/doc/tutorial/fuzz.md
+++ b/_content/doc/tutorial/fuzz.md
@@ -611,7 +611,32 @@ UTF-8.
}
```
-2. Modify the reverse_test.go file to check for errors and skip the test if
+1. Since the Reverse function now returns an error, modify the `main` function to
+ discard the extra error value. Replace the existing `main` function with the
+ following.
+
+ ```
+ func main() {
+ input := "The quick brown fox jumped over the lazy dog"
+ rev, _ := Reverse(input)
+ doubleRev, _ := Reverse(rev)
+ fmt.Printf("original: %q\n", input)
+ fmt.Printf("reversed: %q\n", rev)
+ fmt.Printf("reversed again: %q\n", doubleRev)
+ }
+ ```
+1. Don't forget to import the new errors package. The first lines of main.go
+ should look like the following.
+
+ ```
+ import (
+ "fmt"
+ "errors"
+ "unicode/utf8"
+ )
+ ```
+
+1. Modify the reverse_test.go file to check for errors and skip the test if
errors are generated by returning.
```
@@ -725,12 +750,16 @@ further reading.
```
package main
-import "fmt"
+import (
+ "fmt"
+ "errors"
+ "unicode/utf8"
+)
func main() {
input := "The quick brown fox jumped over the lazy dog"
- rev := Reverse(input)
- doubleRev := Reverse(rev)
+ rev, _ := Reverse(input)
+ doubleRev, _ := Reverse(rev)
fmt.Printf("original: %q\n", input)
fmt.Printf("reversed: %q\n", rev)
fmt.Printf("reversed again: %q\n", doubleRev)