Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1531)

Side by Side Diff: misc/goplay/goplay.go

Issue 4357052: code review 4357052: os: New Open API. (Closed)
Patch Set: Created 12 years, 12 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "exec" 9 "exec"
10 "flag" 10 "flag"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // x is the base name for .go, .6, executable files 76 // x is the base name for .go, .6, executable files
77 x := os.TempDir() + "/compile" + strconv.Itoa(<-uniq) 77 x := os.TempDir() + "/compile" + strconv.Itoa(<-uniq)
78 src := x + ".go" 78 src := x + ".go"
79 obj := x + "." + archChar 79 obj := x + "." + archChar
80 bin := x 80 bin := x
81 if runtime.GOOS == "windows" { 81 if runtime.GOOS == "windows" {
82 bin += ".exe" 82 bin += ".exe"
83 } 83 }
84 84
85 // write request Body to x.go 85 // write request Body to x.go
86 » f, err := os.Open(src, os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0666) 86 » f, err := os.OpenFile(src, os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0666)
rsc 2011/04/04 22:45:44 I think gofix should rewrite this to os.Create.
87 if err != nil { 87 if err != nil {
88 error(w, nil, err) 88 error(w, nil, err)
89 return 89 return
90 } 90 }
91 defer os.Remove(src) 91 defer os.Remove(src)
92 defer f.Close() 92 defer f.Close()
93 _, err = io.Copy(f, req.Body) 93 _, err = io.Copy(f, req.Body)
94 if err != nil { 94 if err != nil {
95 error(w, nil, err) 95 error(w, nil, err)
96 return 96 return
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 ` 305 `
306 306
307 var helloWorld = []byte(`package main 307 var helloWorld = []byte(`package main
308 308
309 import "fmt" 309 import "fmt"
310 310
311 func main() { 311 func main() {
312 fmt.Println("hello, world") 312 fmt.Println("hello, world")
313 } 313 }
314 `) 314 `)
OLDNEW
« no previous file with comments | « misc/dashboard/builder/exec.go ('k') | src/cmd/cgo/main.go » ('j') | src/cmd/gofix/osopen.go » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b