OLD | NEW |
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 Loading... |
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) |
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 Loading... |
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 `) |
OLD | NEW |