]> Cypherpunks repositories - gostls13.git/commitdiff
ghchinoy: add example for ioutil.WriteFile
authorG. Hussain Chinoy <ghchinoy@gmail.com>
Thu, 30 Aug 2018 18:24:53 +0000 (18:24 +0000)
committerBryan C. Mills <bcmills@google.com>
Thu, 30 Aug 2018 18:38:34 +0000 (18:38 +0000)
Change-Id: I65c3bda498562fdf39994ec1cadce7947e2d84b5
Reviewed-on: https://go-review.googlesource.com/132277
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/io/ioutil/example_test.go

index 0b24f672eecdb5abdc4a234b85dc289fd44fd67f..a7d340b77fa595a607dc2d4de1828a8742b241c3 100644 (file)
@@ -99,3 +99,11 @@ func ExampleReadFile() {
        // Output:
        // File contents: Hello, Gophers!
 }
+
+func ExampleWriteFile() {
+       message := []byte("Hello, Gophers!")
+       err := ioutil.WriteFile("testdata/hello", message, 0644)
+       if err != nil {
+               log.Fatal(err)
+       }
+}