Skip to content

io/ioutil: WriteFile example errors when run on the Go Playground #40623

Closed
@mntlty

Description

@mntlty

What version of Go are you using (go version)?

latest

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

Go Playground https://play.golang.org/

What did you do?

run example at https://golang.org/pkg/io/ioutil/#WriteFile which links to https://play.golang.org/p/bIP2HMSXz1u

What did you expect to see?

no error

What did you see instead?

error: `open testdata/hello: no such file or directory

Suggested Fixes

WriteFile does not create a directory, and the code example tries to write to the non-existent directory testdata. Possible solution are either to create this directory in the example code or change the argument to WriteFile to just include the file name

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions