Commit 428d79bd authored by Jaana Burcu Dogan's avatar Jaana Burcu Dogan

os: add example for OpenFile

New beginners are not familiar with open(2)-style masking of the
flags. Add an example demonstrates the flag or'ing.

Change-Id: Ifa8009c55173ba0dc6642c1d3b3124c766b1ebbb
Reviewed-on: https://go-review.googlesource.com/27996Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 650c2c17
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package os_test
import (
"log"
"os"
)
func ExampleOpenFile() {
f, err := os.OpenFile("notes.txt", os.O_RDWR|os.O_CREATE, 0755)
if err != nil {
log.Fatal(err)
}
if err := f.Close(); err != nil {
log.Fatal(err)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment