_content/doc/tutorial: fix fuzz.md final steps
main.go modified to import unicode/utf8 and errors packages, discard
returned error. Steps added to import packages and make changes in final steps.
Fixes golang/go#50628
Change-Id: I5dd5fb66256d56eb81bdbb16ba2d5a3fc1ee5dd4
Reviewed-on: https://go-review.googlesource.com/c/website/+/378477
Trust: Julie Qiu <julieqiu@google.com>
Trust: DO NOT USE <katiehockman@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: DO NOT USE <katiehockman@google.com>
diff --git a/_content/doc/tutorial/fuzz.md b/_content/doc/tutorial/fuzz.md
index 40575f9..0f96ce5 100644
--- a/_content/doc/tutorial/fuzz.md
+++ b/_content/doc/tutorial/fuzz.md
@@ -611,7 +611,32 @@
}
```
-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 @@
```
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)