]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: make build errors more visible
authorRuss Cox <rsc@golang.org>
Thu, 15 Mar 2012 21:35:57 +0000 (17:35 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 15 Mar 2012 21:35:57 +0000 (17:35 -0400)
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

src/cmd/go/build.go
src/cmd/go/clean.go

index 26efaca3e4daf2cb227b04e1e9af00f35a54920e..1cc2dc4ca456b4a01404a114a693729f4079aec0 100644 (file)
@@ -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
 }
index 809e0f0e428992e32e7ce8f40f34a484024df8b8..77395182679e290182137c4dadd0c8fe96c89cf4 100644 (file)
@@ -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
        }