summaryrefslogtreecommitdiff
path: root/src/pkg/go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-08-10 15:05:15 +0200
committerOndřej Surý <ondrej@sury.org>2011-08-10 15:05:15 +0200
commit825e92f34920934f09dbf4c614dbd2913ba464cb (patch)
tree2af4eb446f544e17f65b34ad2b9668d2bb8ab78b /src/pkg/go
parente6b380032482808aee5e4c5222b6d7390f468e74 (diff)
downloadgolang-825e92f34920934f09dbf4c614dbd2913ba464cb.tar.gz
Imported Upstream version 2011.08.10upstream-weekly/2011.08.10
Diffstat (limited to 'src/pkg/go')
-rw-r--r--src/pkg/go/build/path.go5
-rw-r--r--src/pkg/go/scanner/errors.go19
2 files changed, 13 insertions, 11 deletions
diff --git a/src/pkg/go/build/path.go b/src/pkg/go/build/path.go
index 7c120d064..e39b5f8fa 100644
--- a/src/pkg/go/build/path.go
+++ b/src/pkg/go/build/path.go
@@ -54,6 +54,11 @@ func (t *Tree) PkgDir() string {
// BinDir returns the tree's binary executable directory.
func (t *Tree) BinDir() string {
+ if t.Goroot {
+ if gobin := os.Getenv("GOBIN"); gobin != "" {
+ return gobin
+ }
+ }
return filepath.Join(t.Path, "bin")
}
diff --git a/src/pkg/go/scanner/errors.go b/src/pkg/go/scanner/errors.go
index f8e9ffa6f..a0927e416 100644
--- a/src/pkg/go/scanner/errors.go
+++ b/src/pkg/go/scanner/errors.go
@@ -5,7 +5,6 @@
package scanner
import (
- "container/vector"
"fmt"
"go/token"
"io"
@@ -32,14 +31,14 @@ type ErrorHandler interface {
// error handling is obtained.
//
type ErrorVector struct {
- errors vector.Vector
+ errors []*Error
}
// Reset resets an ErrorVector to no errors.
-func (h *ErrorVector) Reset() { h.errors.Resize(0, 0) }
+func (h *ErrorVector) Reset() { h.errors = h.errors[:0] }
// ErrorCount returns the number of errors collected.
-func (h *ErrorVector) ErrorCount() int { return h.errors.Len() }
+func (h *ErrorVector) ErrorCount() int { return len(h.errors) }
// Within ErrorVector, an error is represented by an Error node. The
// position Pos, if valid, points to the beginning of the offending
@@ -110,14 +109,12 @@ const (
// parameter. If there are no errors, the result is nil.
//
func (h *ErrorVector) GetErrorList(mode int) ErrorList {
- if h.errors.Len() == 0 {
+ if len(h.errors) == 0 {
return nil
}
- list := make(ErrorList, h.errors.Len())
- for i := 0; i < h.errors.Len(); i++ {
- list[i] = h.errors.At(i).(*Error)
- }
+ list := make(ErrorList, len(h.errors))
+ copy(list, h.errors)
if mode >= Sorted {
sort.Sort(list)
@@ -144,7 +141,7 @@ func (h *ErrorVector) GetErrorList(mode int) ErrorList {
// remains nil.
//
func (h *ErrorVector) GetError(mode int) os.Error {
- if h.errors.Len() == 0 {
+ if len(h.errors) == 0 {
return nil
}
@@ -153,7 +150,7 @@ func (h *ErrorVector) GetError(mode int) os.Error {
// ErrorVector implements the ErrorHandler interface.
func (h *ErrorVector) Error(pos token.Position, msg string) {
- h.errors.Push(&Error{pos, msg})
+ h.errors = append(h.errors, &Error{pos, msg})
}
// PrintError is a utility function that prints a list of errors to w,