Commit 7a84fb3a authored by Russ Cox's avatar Russ Cox

cmd/go: make build errors more visible

Fixes #3324.

Robert suggested not reporting errors until the end of the output.
which I'd also like to do, but errPrintedOutput makes that a bigger
change than I want to do before Go 1.  This change should at least
remove the confusion we had.

# Building packages and commands for linux/amd64.
runtime
errors
sync/atomic
unicode
unicode/utf8
math
sync
unicode/utf16
crypto/subtle
io
syscall
hash
crypto
crypto/md5
hash/crc32
crypto/cipher
crypto/hmac
crypto/sha1
go install unicode: copying /tmp/go-build816525784/unicode.a to /home/rsc/g/go/pkg/linux_amd64/unicode.a: short write
hash/adler32
container/list
container/ring
...

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5837054
parent 9e03dcb3
......@@ -604,7 +604,12 @@ func (b *builder) do(root *action) {
}
// build is the action for building a single package or command.
func (b *builder) build(a *action) error {
func (b *builder) build(a *action) (err error) {
defer func() {
if err != nil {
err = fmt.Errorf("go build %s: %v", a.p.ImportPath, err)
}
}()
if buildN {
// In -n mode, print a banner between packages.
// The banner is five lines so that when changes to
......@@ -753,7 +758,12 @@ func (b *builder) build(a *action) error {
}
// install is the action for installing a single package or executable.
func (b *builder) install(a *action) error {
func (b *builder) install(a *action) (err error) {
defer func() {
if err != nil {
err = fmt.Errorf("go install %s: %v", a.p.ImportPath, err)
}
}()
a1 := a.deps[0]
perm := os.FileMode(0666)
if a1.link {
......@@ -874,7 +884,7 @@ func (b *builder) copyFile(a *action, dst, src string, perm os.FileMode) error {
df.Close()
if err != nil {
os.Remove(dst)
return err
return fmt.Errorf("copying %s to %s: %v", src, dst, err)
}
return nil
}
......
......@@ -110,7 +110,7 @@ func clean(p *Package) {
}
dirs, err := ioutil.ReadDir(p.Dir)
if err != nil {
errorf("%v", err)
errorf("go clean %s: %v", p.Dir, err)
return
}
......
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