From c7a7ecad260d219c1b693f8d76238a36ba514d71 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Fri, 13 Dec 2013 09:27:07 +1100 Subject: go.blog: add "Inside the Go Playground" article R=r, rsc, dsymonds https://golang.org/cl/39180043 --- content/playground/os.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 content/playground/os.go (limited to 'content/playground/os.go') diff --git a/content/playground/os.go b/content/playground/os.go new file mode 100644 index 0000000..a73beb0 --- /dev/null +++ b/content/playground/os.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "io/ioutil" + "log" +) + +func main() { + const filename = "/tmp/file.txt" + + err := ioutil.WriteFile(filename, []byte("Hello, file system\n"), 0644) + if err != nil { + log.Fatal(err) + } + + b, err := ioutil.ReadFile(filename) + if err != nil { + log.Fatal(err) + } + + fmt.Printf("%s", b) +} -- cgit v1.2.3