github.com/euank/go@v0.0.0-20160829210321-495514729181/src/os/example_test.go (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package os_test 6 7 import ( 8 "log" 9 "os" 10 ) 11 12 func ExampleOpenFile() { 13 f, err := os.OpenFile("notes.txt", os.O_RDWR|os.O_CREATE, 0755) 14 if err != nil { 15 log.Fatal(err) 16 } 17 if err := f.Close(); err != nil { 18 log.Fatal(err) 19 } 20 }