aboutsummaryrefslogtreecommitdiff
path: root/_content/doc/tutorial
diff options
context:
space:
mode:
authorBeth Brown <ecbrown@google.com>2022-01-15 05:43:21 +0000
committerDO NOT USE <katiehockman@google.com>2022-01-19 18:54:03 +0000
commit5c6d3e7309900a7e7a784cc9bce960d4fb7f79b2 (patch)
tree0ed6ba7d7abf1db6a588dfcefb0eec14eb28d4a5 /_content/doc/tutorial
parentc5f7fbcc11d764a97d7b3a9e20693f808221f5dd (diff)
downloadgo-x-website-5c6d3e7309900a7e7a784cc9bce960d4fb7f79b2.tar.xz
_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>
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)