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

Delta Between Two Patch Sets: src/cmd/go/run.go

Issue 7393063: code review 7393063: cmd/go: fix "go run" cgo source when cgo is disabled (Closed)
Left Patch Set: diff -r b2cf2bf50e1f https://code.google.com/p/go/ Created 12 years ago
Right Patch Set: diff -r 38b1893be35d https://code.google.com/p/go/ Created 12 years 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/runtime/crash_cgo_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 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 "fmt" 8 "fmt"
9 "os" 9 "os"
10 "os/exec" 10 "os/exec"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 if p.Name != "main" { 64 if p.Name != "main" {
65 fatalf("go run: cannot run non-main package") 65 fatalf("go run: cannot run non-main package")
66 } 66 }
67 p.target = "" // must build - not up to date 67 p.target = "" // must build - not up to date
68 var src string 68 var src string
69 if len(p.GoFiles) > 0 { 69 if len(p.GoFiles) > 0 {
70 src = p.GoFiles[0] 70 src = p.GoFiles[0]
71 } else if len(p.CgoFiles) > 0 { 71 } else if len(p.CgoFiles) > 0 {
72 src = p.CgoFiles[0] 72 src = p.CgoFiles[0]
73 } else { 73 } else {
74 » » fatalf("go run: no suitable source file (cgo disabled?)") 74 » » // this case could only happen if the provided source uses cgo
adg 2013/02/26 22:01:11 If we're going to give hints (and I have nothing a
75 » » // while cgo is disabled.
76 » » hint := ""
77 » » if !buildContext.CgoEnabled {
78 » » » hint = " (cgo is disabled)"
79 » » }
80 » » fatalf("go run: no suitable source files%s", hint)
75 } 81 }
76 p.exeName = src[:len(src)-len(".go")] // name temporary executable for f irst go file 82 p.exeName = src[:len(src)-len(".go")] // name temporary executable for f irst go file
77 a1 := b.action(modeBuild, modeBuild, p) 83 a1 := b.action(modeBuild, modeBuild, p)
78 a := &action{f: (*builder).runProgram, args: cmdArgs, deps: []*action{a1 }} 84 a := &action{f: (*builder).runProgram, args: cmdArgs, deps: []*action{a1 }}
79 b.do(a) 85 b.do(a)
80 } 86 }
81 87
82 // runProgram is the action for running a binary that has already 88 // runProgram is the action for running a binary that has already
83 // been compiled. We ignore exit status. 89 // been compiled. We ignore exit status.
84 func (b *builder) runProgram(a *action) error { 90 func (b *builder) runProgram(a *action) error {
(...skipping 13 matching lines...) Expand all
98 cmdline := stringList(cmdargs...) 104 cmdline := stringList(cmdargs...)
99 cmd := exec.Command(cmdline[0], cmdline[1:]...) 105 cmd := exec.Command(cmdline[0], cmdline[1:]...)
100 cmd.Stdin = os.Stdin 106 cmd.Stdin = os.Stdin
101 cmd.Stdout = os.Stdout 107 cmd.Stdout = os.Stdout
102 cmd.Stderr = os.Stderr 108 cmd.Stderr = os.Stderr
103 startSigHandlers() 109 startSigHandlers()
104 if err := cmd.Run(); err != nil { 110 if err := cmd.Run(); err != nil {
105 errorf("%v", err) 111 errorf("%v", err)
106 } 112 }
107 } 113 }
LEFTRIGHT

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