            cmd/go: build: print import errors when invoked on files
            cmd/go: build: print import errors when invoked on files

      This fix makes the goFilesPackage helper function print the errors from
      package imports and exit similar to how the packagesForBuild function does.


      Without this change, when invoking "go build *.go" with, for example,
      an old import path, the following stack trace is generated:

      panic: runtime error: invalid memory address or nil pointer dereference

      goroutine 1 [running]:
      go/build.(*Tree).PkgDir(...)
              /opt/go/src/pkg/go/build/path.go:52 +0xfb
      main.(*builder).action(...)
              /opt/go/src/cmd/go/build.go:327 +0xb8
      main.(*builder).action(...)
              /opt/go/src/cmd/go/build.go:335 +0x208
      main.runBuild(...)
              /opt/go/src/cmd/go/build.go:129 +0x386
      main.main()
              /opt/go/src/cmd/go/main.go:126 +0x2d8

Fixes issue 2865.

R=rsc, dvyukov, r
CC=golang-dev
http://codereview.appspot.com/5624052

Committer: Rob Pike <4dc7c9ec434ed06502767136789763ec11d2c4b7@golang.org>
abustany/go,abustany/go,abustany/go,abustany/go,abustany/go,abustany/go,abustany/go