Skip to content

Commit 6d767df

Browse files
committed
io/ioutil: modify example test for WriteFile to allow it to run in the playground
1 parent 682a1d2 commit 6d767df

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/io/ioutil/example_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ func ExampleReadFile() {
125125

126126
func ExampleWriteFile() {
127127
message := []byte("Hello, Gophers!")
128+
129+
if err := os.MkdirAll("testdata", 0755); err != nil {
130+
log.Fatal(err)
131+
}
132+
128133
err := ioutil.WriteFile("testdata/hello", message, 0644)
129134
if err != nil {
130135
log.Fatal(err)

0 commit comments

Comments
 (0)