From abbbdb168d7c5e0cfc09ffe0c2d2ce3b41bf7dca Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Mon, 4 Apr 2011 23:42:14 -0700 Subject: [PATCH] os: New Open API. We replace the current Open with: OpenFile(name, flag, perm) // same as old Open Open(name) // same as old Open(name, O_RDONLY, 0) Create(name) // same as old Open(name, O_RDWR|O_TRUNC|O_CREAT, 0666) This CL includes a gofix module and full code updates: all.bash passes. (There may be a few comments I missed.) The interesting packages are: gofix os Everything else is automatically generated except for hand tweaks to: src/pkg/io/ioutil/ioutil.go src/pkg/io/ioutil/tempfile.go src/pkg/crypto/tls/generate_cert.go src/cmd/goyacc/goyacc.go src/cmd/goyacc/units.y R=golang-dev, bradfitzwork, rsc, r2 CC=golang-dev https://golang.org/cl/4357052 --- generate_cert.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generate_cert.go b/generate_cert.go index ee77f94..5c783fd 100644 --- a/generate_cert.go +++ b/generate_cert.go @@ -50,7 +50,7 @@ func main() { return } - certOut, err := os.Open("cert.pem", os.O_WRONLY|os.O_CREAT, 0644) + certOut, err := os.Create("cert.pem") if err != nil { log.Fatalf("failed to open cert.pem for writing: %s", err) return @@ -59,7 +59,7 @@ func main() { certOut.Close() log.Print("written cert.pem\n") - keyOut, err := os.Open("key.pem", os.O_WRONLY|os.O_CREAT, 0600) + keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREAT, 0600) if err != nil { log.Print("failed to open key.pem for writing:", err) return