summaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/cgo/ast.go12
-rw-r--r--src/cmd/cgo/gcc.go31
-rw-r--r--src/cmd/cgo/main.go4
-rw-r--r--src/cmd/cgo/out.go4
-rw-r--r--src/cmd/cgo/util.go2
-rw-r--r--src/cmd/godoc/appinit.go3
-rw-r--r--src/cmd/godoc/codewalk.go19
-rw-r--r--src/cmd/godoc/filesystem.go18
-rw-r--r--src/cmd/godoc/godoc.go20
-rw-r--r--src/cmd/godoc/httpzip.go14
-rw-r--r--src/cmd/godoc/index.go16
-rw-r--r--src/cmd/godoc/main.go7
-rw-r--r--src/cmd/godoc/parser.go7
-rw-r--r--src/cmd/godoc/utils.go2
-rw-r--r--src/cmd/godoc/zip.go13
-rw-r--r--src/cmd/gofix/main.go12
-rw-r--r--src/cmd/gofmt/gofmt.go14
-rw-r--r--src/cmd/goinstall/download.go35
-rw-r--r--src/cmd/goinstall/main.go17
-rw-r--r--src/cmd/goinstall/make.go16
-rw-r--r--src/cmd/gotest/gotest.go2
-rw-r--r--src/cmd/govet/govet.go4
-rw-r--r--src/cmd/hgpatch/main.go32
23 files changed, 153 insertions, 151 deletions
diff --git a/src/cmd/cgo/ast.go b/src/cmd/cgo/ast.go
index 73b7313d6..d2336ef6d 100644
--- a/src/cmd/cgo/ast.go
+++ b/src/cmd/cgo/ast.go
@@ -71,7 +71,7 @@ func (f *File) ReadGo(name string) {
}
sawC = true
if s.Name != nil {
- error(s.Path.Pos(), `cannot rename import "C"`)
+ error_(s.Path.Pos(), `cannot rename import "C"`)
}
cg := s.Doc
if cg == nil && len(d.Specs) == 1 {
@@ -84,7 +84,7 @@ func (f *File) ReadGo(name string) {
}
}
if !sawC {
- error(token.NoPos, `cannot find import "C"`)
+ error_(token.NoPos, `cannot find import "C"`)
}
// In ast2, strip the import "C" line.
@@ -149,7 +149,7 @@ func (f *File) saveRef(x interface{}, context string) {
}
goname := sel.Sel.Name
if goname == "errno" {
- error(sel.Pos(), "cannot refer to errno directly; see documentation")
+ error_(sel.Pos(), "cannot refer to errno directly; see documentation")
return
}
name := f.Name[goname]
@@ -186,11 +186,11 @@ func (f *File) saveExport(x interface{}, context string) {
name := strings.TrimSpace(string(c.Text[9:]))
if name == "" {
- error(c.Pos(), "export missing name")
+ error_(c.Pos(), "export missing name")
}
if name != n.Name.Name {
- error(c.Pos(), "export comment has wrong name %q, want %q", name, n.Name.Name)
+ error_(c.Pos(), "export comment has wrong name %q, want %q", name, n.Name.Name)
}
f.ExpFunc = append(f.ExpFunc, &ExpFunc{
@@ -225,7 +225,7 @@ func (f *File) walk(x interface{}, context string, visit func(*File, interface{}
// everything else just recurs
default:
- error(token.NoPos, "unexpected type %T in walk", x, visit)
+ error_(token.NoPos, "unexpected type %T in walk", x, visit)
panic("unexpected type")
case nil:
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go
index 97297a860..67744dd0d 100644
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -14,6 +14,7 @@ import (
"debug/macho"
"debug/pe"
"encoding/binary"
+ "errors"
"flag"
"fmt"
"go/ast"
@@ -147,10 +148,10 @@ func (p *Package) addToFlag(flag string, args []string) {
// pkgConfig runs pkg-config and extracts --libs and --cflags information
// for packages.
-func pkgConfig(packages []string) (cflags, ldflags []string, err os.Error) {
+func pkgConfig(packages []string) (cflags, ldflags []string, err error) {
for _, name := range packages {
if len(name) == 0 || name[0] == '-' {
- return nil, nil, os.NewError(fmt.Sprintf("invalid name: %q", name))
+ return nil, nil, errors.New(fmt.Sprintf("invalid name: %q", name))
}
}
@@ -158,7 +159,7 @@ func pkgConfig(packages []string) (cflags, ldflags []string, err os.Error) {
stdout, stderr, ok := run(nil, args)
if !ok {
os.Stderr.Write(stderr)
- return nil, nil, os.NewError("pkg-config failed")
+ return nil, nil, errors.New("pkg-config failed")
}
cflags, err = splitQuoted(string(stdout))
if err != nil {
@@ -169,7 +170,7 @@ func pkgConfig(packages []string) (cflags, ldflags []string, err os.Error) {
stdout, stderr, ok = run(nil, args)
if !ok {
os.Stderr.Write(stderr)
- return nil, nil, os.NewError("pkg-config failed")
+ return nil, nil, errors.New("pkg-config failed")
}
ldflags, err = splitQuoted(string(stdout))
return
@@ -191,7 +192,7 @@ func pkgConfig(packages []string) (cflags, ldflags []string, err os.Error) {
//
// []string{"a", "b:c d", "ef", `g"`}
//
-func splitQuoted(s string) (r []string, err os.Error) {
+func splitQuoted(s string) (r []string, err error) {
var args []string
arg := make([]rune, len(s))
escaped := false
@@ -229,9 +230,9 @@ func splitQuoted(s string) (r []string, err os.Error) {
args = append(args, string(arg[:i]))
}
if quote != 0 {
- err = os.NewError("unclosed quote")
+ err = errors.New("unclosed quote")
} else if escaped {
- err = os.NewError("unfinished escaping")
+ err = errors.New("unfinished escaping")
}
return args, err
}
@@ -420,7 +421,7 @@ func (p *Package) guessKinds(f *File) []*Name {
case strings.Contains(line, ": statement with no effect"):
what = "not-type" // const or func or var
case strings.Contains(line, "undeclared"):
- error(token.NoPos, "%s", strings.TrimSpace(line[colon+1:]))
+ error_(token.NoPos, "%s", strings.TrimSpace(line[colon+1:]))
case strings.Contains(line, "is not an integer constant"):
isConst[i] = false
continue
@@ -448,7 +449,7 @@ func (p *Package) guessKinds(f *File) []*Name {
if n.Kind != "" {
continue
}
- error(token.NoPos, "could not determine kind of name for C.%s", n.Go)
+ error_(token.NoPos, "could not determine kind of name for C.%s", n.Go)
}
if nerrors > 0 {
fatalf("unresolved names")
@@ -617,7 +618,7 @@ func (p *Package) rewriteRef(f *File) {
// functions are only used in calls.
for _, r := range f.Ref {
if r.Name.Kind == "const" && r.Name.Const == "" {
- error(r.Pos(), "unable to find value of constant C.%s", r.Name.Go)
+ error_(r.Pos(), "unable to find value of constant C.%s", r.Name.Go)
}
var expr ast.Expr = ast.NewIdent(r.Name.Mangle) // default
switch r.Context {
@@ -628,12 +629,12 @@ func (p *Package) rewriteRef(f *File) {
expr = r.Name.Type.Go
break
}
- error(r.Pos(), "call of non-function C.%s", r.Name.Go)
+ error_(r.Pos(), "call of non-function C.%s", r.Name.Go)
break
}
if r.Context == "call2" {
if r.Name.FuncType.Result == nil {
- error(r.Pos(), "assignment count mismatch: 2 = 0")
+ error_(r.Pos(), "assignment count mismatch: 2 = 0")
}
// Invent new Name for the two-result function.
n := f.Name["2"+r.Name.Go]
@@ -650,7 +651,7 @@ func (p *Package) rewriteRef(f *File) {
}
case "expr":
if r.Name.Kind == "func" {
- error(r.Pos(), "must call C.%s", r.Name.Go)
+ error_(r.Pos(), "must call C.%s", r.Name.Go)
}
if r.Name.Kind == "type" {
// Okay - might be new(T)
@@ -662,13 +663,13 @@ func (p *Package) rewriteRef(f *File) {
case "type":
if r.Name.Kind != "type" {
- error(r.Pos(), "expression C.%s used as type", r.Name.Go)
+ error_(r.Pos(), "expression C.%s used as type", r.Name.Go)
} else {
expr = r.Name.Type.Go
}
default:
if r.Name.Kind == "func" {
- error(r.Pos(), "must call C.%s", r.Name.Go)
+ error_(r.Pos(), "must call C.%s", r.Name.Go)
}
}
*r.Expr = expr
diff --git a/src/cmd/cgo/main.go b/src/cmd/cgo/main.go
index 106698114..7cc0795b0 100644
--- a/src/cmd/cgo/main.go
+++ b/src/cmd/cgo/main.go
@@ -255,7 +255,7 @@ func (p *Package) Record(f *File) {
if p.PackageName == "" {
p.PackageName = f.Package
} else if p.PackageName != f.Package {
- error(token.NoPos, "inconsistent package names: %s, %s", p.PackageName, f.Package)
+ error_(token.NoPos, "inconsistent package names: %s, %s", p.PackageName, f.Package)
}
if p.Name == nil {
@@ -265,7 +265,7 @@ func (p *Package) Record(f *File) {
if p.Name[k] == nil {
p.Name[k] = v
} else if !reflect.DeepEqual(p.Name[k], v) {
- error(token.NoPos, "inconsistent definitions for C.%s", k)
+ error_(token.NoPos, "inconsistent definitions for C.%s", k)
}
}
}
diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go
index 7f65f0644..25f4f3e66 100644
--- a/src/cmd/cgo/out.go
+++ b/src/cmd/cgo/out.go
@@ -650,7 +650,7 @@ func (p *Package) cgoType(e ast.Expr) *Type {
}
return r
}
- error(e.Pos(), "unrecognized Go type %s", t.Name)
+ error_(e.Pos(), "unrecognized Go type %s", t.Name)
return &Type{Size: 4, Align: 4, C: c("int")}
case *ast.SelectorExpr:
id, ok := t.X.(*ast.Ident)
@@ -658,7 +658,7 @@ func (p *Package) cgoType(e ast.Expr) *Type {
return &Type{Size: p.PtrSize, Align: p.PtrSize, C: c("void*")}
}
}
- error(e.Pos(), "unrecognized Go type %T", e)
+ error_(e.Pos(), "unrecognized Go type %T", e)
return &Type{Size: 4, Align: 4, C: c("int")}
}
diff --git a/src/cmd/cgo/util.go b/src/cmd/cgo/util.go
index a9c4e8fde..b4a83bf12 100644
--- a/src/cmd/cgo/util.go
+++ b/src/cmd/cgo/util.go
@@ -72,7 +72,7 @@ func fatalf(msg string, args ...interface{}) {
var nerrors int
-func error(pos token.Pos, msg string, args ...interface{}) {
+func error_(pos token.Pos, msg string, args ...interface{}) {
nerrors++
if pos.IsValid() {
fmt.Fprintf(os.Stderr, "%s: ", fset.Position(pos).String())
diff --git a/src/cmd/godoc/appinit.go b/src/cmd/godoc/appinit.go
index 355d638b0..37c55451a 100644
--- a/src/cmd/godoc/appinit.go
+++ b/src/cmd/godoc/appinit.go
@@ -11,11 +11,10 @@ import (
"archive/zip"
"http"
"log"
- "os"
"path"
)
-func serveError(w http.ResponseWriter, r *http.Request, relpath string, err os.Error) {
+func serveError(w http.ResponseWriter, r *http.Request, relpath string, err error) {
contents := applyTemplate(errorHTML, "errorHTML", err) // err may contain an absolute path!
w.WriteHeader(http.StatusNotFound)
servePage(w, "File "+relpath, "", "", contents)
diff --git a/src/cmd/godoc/codewalk.go b/src/cmd/godoc/codewalk.go
index 39f1fd5cb..6f25769a3 100644
--- a/src/cmd/godoc/codewalk.go
+++ b/src/cmd/godoc/codewalk.go
@@ -13,6 +13,7 @@
package main
import (
+ "errors"
"fmt"
"http"
"io"
@@ -84,7 +85,7 @@ type Codestep struct {
XML string `xml:"innerxml"`
// Derived from Src; not in XML.
- Err os.Error
+ Err error
File string
Lo int
LoByte int
@@ -107,7 +108,7 @@ func (st *Codestep) String() string {
}
// loadCodewalk reads a codewalk from the named XML file.
-func loadCodewalk(filename string) (*Codewalk, os.Error) {
+func loadCodewalk(filename string) (*Codewalk, error) {
f, err := fs.Open(filename)
if err != nil {
return nil, err
@@ -252,7 +253,7 @@ func codewalkFileprint(w http.ResponseWriter, r *http.Request, f string) {
// It returns the lo and hi byte offset of the matched region within data.
// See http://plan9.bell-labs.com/sys/doc/sam/sam.html Table II
// for details on the syntax.
-func addrToByteRange(addr string, start int, data []byte) (lo, hi int, err os.Error) {
+func addrToByteRange(addr string, start int, data []byte) (lo, hi int, err error) {
var (
dir byte
prevc byte
@@ -264,7 +265,7 @@ func addrToByteRange(addr string, start int, data []byte) (lo, hi int, err os.Er
c := addr[0]
switch c {
default:
- err = os.NewError("invalid address syntax near " + string(c))
+ err = errors.New("invalid address syntax near " + string(c))
case ',':
if len(addr) == 1 {
hi = len(data)
@@ -348,7 +349,7 @@ func addrToByteRange(addr string, start int, data []byte) (lo, hi int, err os.Er
// (or characters) after hi. Applying -n (or -#n) means to back up n lines
// (or characters) before lo.
// The return value is the new lo, hi.
-func addrNumber(data []byte, lo, hi int, dir byte, n int, charOffset bool) (int, int, os.Error) {
+func addrNumber(data []byte, lo, hi int, dir byte, n int, charOffset bool) (int, int, error) {
switch dir {
case 0:
lo = 0
@@ -424,13 +425,13 @@ func addrNumber(data []byte, lo, hi int, dir byte, n int, charOffset bool) (int,
}
}
- return 0, 0, os.NewError("address out of range")
+ return 0, 0, errors.New("address out of range")
}
// addrRegexp searches for pattern in the given direction starting at lo, hi.
// The direction dir is '+' (search forward from hi) or '-' (search backward from lo).
// Backward searches are unimplemented.
-func addrRegexp(data []byte, lo, hi int, dir byte, pattern string) (int, int, os.Error) {
+func addrRegexp(data []byte, lo, hi int, dir byte, pattern string) (int, int, error) {
re, err := regexp.Compile(pattern)
if err != nil {
return 0, 0, err
@@ -438,7 +439,7 @@ func addrRegexp(data []byte, lo, hi int, dir byte, pattern string) (int, int, os
if dir == '-' {
// Could implement reverse search using binary search
// through file, but that seems like overkill.
- return 0, 0, os.NewError("reverse search not implemented")
+ return 0, 0, errors.New("reverse search not implemented")
}
m := re.FindIndex(data[hi:])
if len(m) > 0 {
@@ -449,7 +450,7 @@ func addrRegexp(data []byte, lo, hi int, dir byte, pattern string) (int, int, os
m = re.FindIndex(data)
}
if len(m) == 0 {
- return 0, 0, os.NewError("no match for " + pattern)
+ return 0, 0, errors.New("no match for " + pattern)
}
return m[0], m[1], nil
}
diff --git a/src/cmd/godoc/filesystem.go b/src/cmd/godoc/filesystem.go
index 011977af9..ece9ebbf3 100644
--- a/src/cmd/godoc/filesystem.go
+++ b/src/cmd/godoc/filesystem.go
@@ -27,14 +27,14 @@ type FileInfo interface {
// The FileSystem interface specifies the methods godoc is using
// to access the file system for which it serves documentation.
type FileSystem interface {
- Open(path string) (io.ReadCloser, os.Error)
- Lstat(path string) (FileInfo, os.Error)
- Stat(path string) (FileInfo, os.Error)
- ReadDir(path string) ([]FileInfo, os.Error)
+ Open(path string) (io.ReadCloser, error)
+ Lstat(path string) (FileInfo, error)
+ Stat(path string) (FileInfo, error)
+ ReadDir(path string) ([]FileInfo, error)
}
// ReadFile reads the file named by path from fs and returns the contents.
-func ReadFile(fs FileSystem, path string) ([]byte, os.Error) {
+func ReadFile(fs FileSystem, path string) ([]byte, error) {
rc, err := fs.Open(path)
if err != nil {
return nil, err
@@ -71,7 +71,7 @@ func (fi osFI) Mtime_ns() int64 {
// osFS is the OS-specific implementation of FileSystem
type osFS struct{}
-func (osFS) Open(path string) (io.ReadCloser, os.Error) {
+func (osFS) Open(path string) (io.ReadCloser, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
@@ -86,17 +86,17 @@ func (osFS) Open(path string) (io.ReadCloser, os.Error) {
return f, nil
}
-func (osFS) Lstat(path string) (FileInfo, os.Error) {
+func (osFS) Lstat(path string) (FileInfo, error) {
fi, err := os.Lstat(path)
return osFI{fi}, err
}
-func (osFS) Stat(path string) (FileInfo, os.Error) {
+func (osFS) Stat(path string) (FileInfo, error) {
fi, err := os.Stat(path)
return osFI{fi}, err
}
-func (osFS) ReadDir(path string) ([]FileInfo, os.Error) {
+func (osFS) ReadDir(path string) ([]FileInfo, error) {
l0, err := ioutil.ReadDir(path) // l0 is sorted
if err != nil {
return nil, err
diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go
index d436898a2..0d82a1504 100644
--- a/src/cmd/godoc/godoc.go
+++ b/src/cmd/godoc/godoc.go
@@ -148,7 +148,7 @@ func getPathFilter() func(string) bool {
// readDirList reads a file containing a newline-separated list
// of directory paths and returns the list of paths.
-func readDirList(filename string) ([]string, os.Error) {
+func readDirList(filename string) ([]string, error) {
contents, err := ReadFile(fs, filename)
if err != nil {
return nil, err
@@ -299,7 +299,7 @@ type tconv struct {
indent int // valid if state == indenting
}
-func (p *tconv) writeIndent() (err os.Error) {
+func (p *tconv) writeIndent() (err error) {
i := p.indent
for i >= len(spaces) {
i -= len(spaces)
@@ -314,7 +314,7 @@ func (p *tconv) writeIndent() (err os.Error) {
return
}
-func (p *tconv) Write(data []byte) (n int, err os.Error) {
+func (p *tconv) Write(data []byte) (n int, err error) {
if len(data) == 0 {
return
}
@@ -855,7 +855,7 @@ type PageInfo struct {
Dirs *DirList // nil if no directory information
DirTime int64 // directory time stamp in seconds since epoch
IsPkg bool // false if this is not documenting a real package
- Err os.Error // directory read error or nil
+ Err error // directory read error or nil
}
func (info *PageInfo) IsEmpty() bool {
@@ -869,7 +869,7 @@ type httpHandler struct {
}
// fsReadDir implements ReadDir for the go/build package.
-func fsReadDir(dir string) ([]*os.FileInfo, os.Error) {
+func fsReadDir(dir string) ([]*os.FileInfo, error) {
fi, err := fs.ReadDir(dir)
if err != nil {
return nil, err
@@ -888,7 +888,7 @@ func fsReadDir(dir string) ([]*os.FileInfo, os.Error) {
}
// fsReadFile implements ReadFile for the go/build package.
-func fsReadFile(dir, name string) (path string, data []byte, err os.Error) {
+func fsReadFile(dir, name string) (path string, data []byte, err error) {
path = filepath.Join(dir, name)
data, err = ReadFile(fs, path)
return
@@ -1172,12 +1172,12 @@ func lookup(query string) (result SearchResult) {
index := index.(*Index)
// identifier search
- var err os.Error
+ var err error
result.Pak, result.Hit, result.Alt, err = index.Lookup(query)
if err != nil && *maxResults <= 0 {
// ignore the error if full text search is enabled
// since the query may be a valid regular expression
- result.Alert = "Error in query string: " + err.String()
+ result.Alert = "Error in query string: " + err.Error()
return
}
@@ -1185,7 +1185,7 @@ func lookup(query string) (result SearchResult) {
if *maxResults > 0 && query != "" {
rx, err := regexp.Compile(query)
if err != nil {
- result.Alert = "Error in query regular expression: " + err.String()
+ result.Alert = "Error in query regular expression: " + err.Error()
return
}
// If we get maxResults+1 results we know that there are more than
@@ -1280,7 +1280,7 @@ func fsDirnames() <-chan string {
return c
}
-func readIndex(filenames string) os.Error {
+func readIndex(filenames string) error {
matches, err := filepath.Glob(filenames)
if err != nil {
return err
diff --git a/src/cmd/godoc/httpzip.go b/src/cmd/godoc/httpzip.go
index cb8322ee4..3e25b6473 100644
--- a/src/cmd/godoc/httpzip.go
+++ b/src/cmd/godoc/httpzip.go
@@ -50,7 +50,7 @@ type httpZipFile struct {
list zipList
}
-func (f *httpZipFile) Close() os.Error {
+func (f *httpZipFile) Close() error {
if f.info.IsRegular() {
return f.ReadCloser.Close()
}
@@ -58,11 +58,11 @@ func (f *httpZipFile) Close() os.Error {
return nil
}
-func (f *httpZipFile) Stat() (*os.FileInfo, os.Error) {
+func (f *httpZipFile) Stat() (*os.FileInfo, error) {
return &f.info, nil
}
-func (f *httpZipFile) Readdir(count int) ([]os.FileInfo, os.Error) {
+func (f *httpZipFile) Readdir(count int) ([]os.FileInfo, error) {
var list []os.FileInfo
dirname := f.path + "/"
prevname := ""
@@ -106,13 +106,13 @@ func (f *httpZipFile) Readdir(count int) ([]os.FileInfo, os.Error) {
}
if count >= 0 && len(list) == 0 {
- return nil, os.EOF
+ return nil, io.EOF
}
return list, nil
}
-func (f *httpZipFile) Seek(offset int64, whence int) (int64, os.Error) {
+func (f *httpZipFile) Seek(offset int64, whence int) (int64, error) {
return 0, fmt.Errorf("Seek not implemented for zip file entry: %s", f.info.Name)
}
@@ -123,7 +123,7 @@ type httpZipFS struct {
root string
}
-func (fs *httpZipFS) Open(name string) (http.File, os.Error) {
+func (fs *httpZipFS) Open(name string) (http.File, error) {
// fs.root does not start with '/'.
path := path.Join(fs.root, name) // path is clean
index, exact := fs.list.lookup(path)
@@ -165,7 +165,7 @@ func (fs *httpZipFS) Open(name string) (http.File, os.Error) {
}, nil
}
-func (fs *httpZipFS) Close() os.Error {
+func (fs *httpZipFS) Close() error {
fs.list = nil
return fs.ReadCloser.Close()
}
diff --git a/src/cmd/godoc/index.go b/src/cmd/godoc/index.go
index 4f687ea83..68d1abe64 100644
--- a/src/cmd/godoc/index.go
+++ b/src/cmd/godoc/index.go
@@ -40,6 +40,7 @@ package main
import (
"bufio"
"bytes"
+ "errors"
"go/ast"
"go/parser"
"go/token"
@@ -47,7 +48,6 @@ import (
"gob"
"index/suffixarray"
"io"
- "os"
"path/filepath"
"regexp"
"sort"
@@ -841,16 +841,16 @@ type fileIndex struct {
Fulltext bool
}
-func (x *fileIndex) Write(w io.Writer) os.Error {
+func (x *fileIndex) Write(w io.Writer) error {
return gob.NewEncoder(w).Encode(x)
}
-func (x *fileIndex) Read(r io.Reader) os.Error {
+func (x *fileIndex) Read(r io.Reader) error {
return gob.NewDecoder(r).Decode(x)
}
// Write writes the index x to w.
-func (x *Index) Write(w io.Writer) os.Error {
+func (x *Index) Write(w io.Writer) error {
fulltext := false
if x.suffixes != nil {
fulltext = true
@@ -877,7 +877,7 @@ func (x *Index) Write(w io.Writer) os.Error {
// Read reads the index from r into x; x must not be nil.
// If r does not also implement io.ByteReader, it will be wrapped in a bufio.Reader.
-func (x *Index) Read(r io.Reader) os.Error {
+func (x *Index) Read(r io.Reader) error {
// We use the ability to read bytes as a plausible surrogate for buffering.
if _, ok := r.(io.ByteReader); !ok {
r = bufio.NewReader(r)
@@ -934,13 +934,13 @@ func isIdentifier(s string) bool {
// identifier, Lookup returns a list of packages, a LookupResult, and a
// list of alternative spellings, if any. Any and all results may be nil.
// If the query syntax is wrong, an error is reported.
-func (x *Index) Lookup(query string) (paks HitList, match *LookupResult, alt *AltWords, err os.Error) {
+func (x *Index) Lookup(query string) (paks HitList, match *LookupResult, alt *AltWords, err error) {
ss := strings.Split(query, ".")
// check query syntax
for _, s := range ss {
if !isIdentifier(s) {
- err = os.NewError("all query parts must be identifiers")
+ err = errors.New("all query parts must be identifiers")
return
}
}
@@ -968,7 +968,7 @@ func (x *Index) Lookup(query string) (paks HitList, match *LookupResult, alt *Al
}
default:
- err = os.NewError("query is not a (qualified) identifier")
+ err = errors.New("query is not a (qualified) identifier")
}
return
diff --git a/src/cmd/godoc/main.go b/src/cmd/godoc/main.go
index d05e03e0b..1a8db4708 100644
--- a/src/cmd/godoc/main.go
+++ b/src/cmd/godoc/main.go
@@ -28,6 +28,7 @@ package main
import (
"archive/zip"
"bytes"
+ "errors"
_ "expvar" // to serve /debug/vars
"flag"
"fmt"
@@ -74,7 +75,7 @@ var (
query = flag.Bool("q", false, "arguments are considered search queries")
)
-func serveError(w http.ResponseWriter, r *http.Request, relpath string, err os.Error) {
+func serveError(w http.ResponseWriter, r *http.Request, relpath string, err error) {
contents := applyTemplate(errorHTML, "errorHTML", err) // err may contain an absolute path!
w.WriteHeader(http.StatusNotFound)
servePage(w, "File "+relpath, "", "", contents)
@@ -163,7 +164,7 @@ func loggingHandler(h http.Handler) http.Handler {
})
}
-func remoteSearch(query string) (res *http.Response, err os.Error) {
+func remoteSearch(query string) (res *http.Response, err error) {
search := "/search?f=text&q=" + url.QueryEscape(query)
// list of addresses to try
@@ -188,7 +189,7 @@ func remoteSearch(query string) (res *http.Response, err os.Error) {
}
if err == nil && res.StatusCode != http.StatusOK {
- err = os.NewError(res.Status)
+ err = errors.New(res.Status)
}
return
diff --git a/src/cmd/godoc/parser.go b/src/cmd/godoc/parser.go
index a2920539f..7597a00e7 100644
--- a/src/cmd/godoc/parser.go
+++ b/src/cmd/godoc/parser.go
@@ -13,11 +13,10 @@ import (
"go/ast"
"go/parser"
"go/token"
- "os"
"path/filepath"
)
-func parseFile(fset *token.FileSet, filename string, mode uint) (*ast.File, os.Error) {
+func parseFile(fset *token.FileSet, filename string, mode uint) (*ast.File, error) {
src, err := ReadFile(fs, filename)
if err != nil {
return nil, err
@@ -25,7 +24,7 @@ func parseFile(fset *token.FileSet, filename string, mode uint) (*ast.File, os.E
return parser.ParseFile(fset, filename, src, mode)
}
-func parseFiles(fset *token.FileSet, filenames []string) (pkgs map[string]*ast.Package, first os.Error) {
+func parseFiles(fset *token.FileSet, filenames []string) (pkgs map[string]*ast.Package, first error) {
pkgs = make(map[string]*ast.Package)
for _, filename := range filenames {
file, err := parseFile(fset, filename, parser.ParseComments)
@@ -48,7 +47,7 @@ func parseFiles(fset *token.FileSet, filenames []string) (pkgs map[string]*ast.P
return
}
-func parseDir(fset *token.FileSet, path string, filter func(FileInfo) bool) (map[string]*ast.Package, os.Error) {
+func parseDir(fset *token.FileSet, path string, filter func(FileInfo) bool) (map[string]*ast.Package, error) {
list, err := fs.ReadDir(path)
if err != nil {
return nil, err
diff --git a/src/cmd/godoc/utils.go b/src/cmd/godoc/utils.go
index 11e46aee5..9ab5f8335 100644
--- a/src/cmd/godoc/utils.go
+++ b/src/cmd/godoc/utils.go
@@ -93,7 +93,7 @@ func canonicalizePaths(list []string, filter func(path string) bool) []string {
// writeFileAtomically writes data to a temporary file and then
// atomically renames that file to the file named by filename.
//
-func writeFileAtomically(filename string, data []byte) os.Error {
+func writeFileAtomically(filename string, data []byte) error {
// TODO(gri) this won't work on appengine
f, err := ioutil.TempFile(filepath.Split(filename))
if err != nil {
diff --git a/src/cmd/godoc/zip.go b/src/cmd/godoc/zip.go
index 86cd79b17..201214222 100644
--- a/src/cmd/godoc/zip.go
+++ b/src/cmd/godoc/zip.go
@@ -22,7 +22,6 @@ import (
"archive/zip"
"fmt"
"io"
- "os"
"path"
"sort"
"strings"
@@ -66,7 +65,7 @@ type zipFS struct {
list zipList
}
-func (fs *zipFS) Close() os.Error {
+func (fs *zipFS) Close() error {
fs.list = nil
return fs.ReadCloser.Close()
}
@@ -79,7 +78,7 @@ func zipPath(name string) string {
return name[1:] // strip leading '/'
}
-func (fs *zipFS) stat(abspath string) (int, zipFI, os.Error) {
+func (fs *zipFS) stat(abspath string) (int, zipFI, error) {
i, exact := fs.list.lookup(abspath)
if i < 0 {
// abspath has leading '/' stripped - print it explicitly
@@ -93,7 +92,7 @@ func (fs *zipFS) stat(abspath string) (int, zipFI, os.Error) {
return i, zipFI{name, file}, nil
}
-func (fs *zipFS) Open(abspath string) (io.ReadCloser, os.Error) {
+func (fs *zipFS) Open(abspath string) (io.ReadCloser, error) {
_, fi, err := fs.stat(zipPath(abspath))
if err != nil {
return nil, err
@@ -104,17 +103,17 @@ func (fs *zipFS) Open(abspath string) (io.ReadCloser, os.Error) {
return fi.file.Open()
}
-func (fs *zipFS) Lstat(abspath string) (FileInfo, os.Error) {
+func (fs *zipFS) Lstat(abspath string) (FileInfo, error) {
_, fi, err := fs.stat(zipPath(abspath))
return fi, err
}
-func (fs *zipFS) Stat(abspath string) (FileInfo, os.Error) {
+func (fs *zipFS) Stat(abspath string) (FileInfo, error) {
_, fi, err := fs.stat(zipPath(abspath))
return fi, err
}
-func (fs *zipFS) ReadDir(abspath string) ([]FileInfo, os.Error) {
+func (fs *zipFS) ReadDir(abspath string) ([]FileInfo, error) {
path := zipPath(abspath)
i, fi, err := fs.stat(path)
if err != nil {
diff --git a/src/cmd/gofix/main.go b/src/cmd/gofix/main.go
index 56232d708..f462c3dfb 100644
--- a/src/cmd/gofix/main.go
+++ b/src/cmd/gofix/main.go
@@ -102,9 +102,9 @@ var printConfig = &printer.Config{
tabWidth,
}
-func processFile(filename string, useStdin bool) os.Error {
+func processFile(filename string, useStdin bool) error {
var f *os.File
- var err os.Error
+ var err error
var fixlog bytes.Buffer
var buf bytes.Buffer
@@ -196,12 +196,12 @@ func gofmt(n interface{}) string {
gofmtBuf.Reset()
_, err := printConfig.Fprint(&gofmtBuf, fset, n)
if err != nil {
- return "<" + err.String() + ">"
+ return "<" + err.Error() + ">"
}
return gofmtBuf.String()
}
-func report(err os.Error) {
+func report(err error) {
scanner.PrintError(os.Stderr, err)
exitCode = 2
}
@@ -210,7 +210,7 @@ func walkDir(path string) {
filepath.Walk(path, visitFile)
}
-func visitFile(path string, f *os.FileInfo, err os.Error) os.Error {
+func visitFile(path string, f *os.FileInfo, err error) error {
if err == nil && isGoFile(f) {
err = processFile(path, false)
}
@@ -225,7 +225,7 @@ func isGoFile(f *os.FileInfo) bool {
return f.IsRegular() && !strings.HasPrefix(f.Name, ".") && strings.HasSuffix(f.Name, ".go")
}
-func diff(b1, b2 []byte) (data []byte, err os.Error) {
+func diff(b1, b2 []byte) (data []byte, err error) {
f1, err := ioutil.TempFile("", "gofix")
if err != nil {
return nil, err
diff --git a/src/cmd/gofmt/gofmt.go b/src/cmd/gofmt/gofmt.go
index 6ce99113e..f5afa6f91 100644
--- a/src/cmd/gofmt/gofmt.go
+++ b/src/cmd/gofmt/gofmt.go
@@ -49,7 +49,7 @@ var (
printerMode uint
)
-func report(err os.Error) {
+func report(err error) {
scanner.PrintError(os.Stderr, err)
exitCode = 2
}
@@ -86,7 +86,7 @@ func isGoFile(f *os.FileInfo) bool {
}
// If in == nil, the source is the contents of the file with the given filename.
-func processFile(filename string, in io.Reader, out io.Writer, stdin bool) os.Error {
+func processFile(filename string, in io.Reader, out io.Writer, stdin bool) error {
if in == nil {
f, err := os.Open(filename)
if err != nil {
@@ -156,7 +156,7 @@ func processFile(filename string, in io.Reader, out io.Writer, stdin bool) os.Er
return err
}
-func visitFile(path string, f *os.FileInfo, err os.Error) os.Error {
+func visitFile(path string, f *os.FileInfo, err error) error {
if err == nil && isGoFile(f) {
err = processFile(path, nil, os.Stdout, false)
}
@@ -225,7 +225,7 @@ func gofmtMain() {
}
}
-func diff(b1, b2 []byte) (data []byte, err os.Error) {
+func diff(b1, b2 []byte) (data []byte, err error) {
f1, err := ioutil.TempFile("", "gofmt")
if err != nil {
return
@@ -255,7 +255,7 @@ func diff(b1, b2 []byte) (data []byte, err os.Error) {
// parse parses src, which was read from filename,
// as a Go source file or statement list.
-func parse(filename string, src []byte, stdin bool) (*ast.File, func(orig, src []byte) []byte, os.Error) {
+func parse(filename string, src []byte, stdin bool) (*ast.File, func(orig, src []byte) []byte, error) {
// Try as whole source file.
file, err := parser.ParseFile(fset, filename, src, parserMode)
if err == nil {
@@ -264,7 +264,7 @@ func parse(filename string, src []byte, stdin bool) (*ast.File, func(orig, src [
// If the error is that the source file didn't begin with a
// package line and this is standard input, fall through to
// try as a source fragment. Stop and return on any other error.
- if !stdin || !strings.Contains(err.String(), "expected 'package'") {
+ if !stdin || !strings.Contains(err.Error(), "expected 'package'") {
return nil, nil, err
}
@@ -286,7 +286,7 @@ func parse(filename string, src []byte, stdin bool) (*ast.File, func(orig, src [
// If the error is that the source file didn't begin with a
// declaration, fall through to try as a statement list.
// Stop and return on any other error.
- if !strings.Contains(err.String(), "expected declaration") {
+ if !strings.Contains(err.Error(), "expected declaration") {
return nil, nil, err
}
diff --git a/src/cmd/goinstall/download.go b/src/cmd/goinstall/download.go
index 28924c70e..927970a45 100644
--- a/src/cmd/goinstall/download.go
+++ b/src/cmd/goinstall/download.go
@@ -8,6 +8,7 @@ package main
import (
"bytes"
+ "errors"
"exec"
"fmt"
"http"
@@ -120,7 +121,7 @@ var vcsList = []*vcs{&git, &hg, &bzr, &svn}
type host struct {
pattern *regexp.Regexp
- getVcs func(repo, path string) (*vcsMatch, os.Error)
+ getVcs func(repo, path string) (*vcsMatch, error)
}
var knownHosts = []host{
@@ -147,7 +148,7 @@ type vcsMatch struct {
prefix, repo string
}
-func googleVcs(repo, path string) (*vcsMatch, os.Error) {
+func googleVcs(repo, path string) (*vcsMatch, error) {
parts := strings.SplitN(repo, "/", 2)
url := "https://" + repo
switch parts[1] {
@@ -158,21 +159,21 @@ func googleVcs(repo, path string) (*vcsMatch, os.Error) {
case "hg":
return &vcsMatch{&hg, repo, url}, nil
}
- return nil, os.NewError("unsupported googlecode vcs: " + parts[1])
+ return nil, errors.New("unsupported googlecode vcs: " + parts[1])
}
-func githubVcs(repo, path string) (*vcsMatch, os.Error) {
+func githubVcs(repo, path string) (*vcsMatch, error) {
if strings.HasSuffix(repo, ".git") {
- return nil, os.NewError("path must not include .git suffix")
+ return nil, errors.New("path must not include .git suffix")
}
return &vcsMatch{&git, repo, "http://" + repo + ".git"}, nil
}
-func bitbucketVcs(repo, path string) (*vcsMatch, os.Error) {
+func bitbucketVcs(repo, path string) (*vcsMatch, error) {
const bitbucketApiUrl = "https://api.bitbucket.org/1.0/repositories/"
if strings.HasSuffix(repo, ".git") {
- return nil, os.NewError("path must not include .git suffix")
+ return nil, errors.New("path must not include .git suffix")
}
parts := strings.SplitN(repo, "/", 2)
@@ -205,16 +206,16 @@ func bitbucketVcs(repo, path string) (*vcsMatch, os.Error) {
return &vcsMatch{&hg, repo, "http://" + repo}, nil
}
- return nil, os.NewError("unsupported bitbucket vcs: " + response.Vcs)
+ return nil, errors.New("unsupported bitbucket vcs: " + response.Vcs)
}
-func launchpadVcs(repo, path string) (*vcsMatch, os.Error) {
+func launchpadVcs(repo, path string) (*vcsMatch, error) {
return &vcsMatch{&bzr, repo, "https://" + repo}, nil
}
// findPublicRepo checks whether pkg is located at one of
// the supported code hosting sites and, if so, returns a match.
-func findPublicRepo(pkg string) (*vcsMatch, os.Error) {
+func findPublicRepo(pkg string) (*vcsMatch, error) {
for _, host := range knownHosts {
if hm := host.pattern.FindStringSubmatch(pkg); hm != nil {
return host.getVcs(hm[1], hm[2])
@@ -224,7 +225,7 @@ func findPublicRepo(pkg string) (*vcsMatch, os.Error) {
}
// findAnyRepo looks for a vcs suffix in pkg (.git, etc) and returns a match.
-func findAnyRepo(pkg string) (*vcsMatch, os.Error) {
+func findAnyRepo(pkg string) (*vcsMatch, error) {
for _, v := range vcsList {
i := strings.Index(pkg+"/", v.suffix+"/")
if i < 0 {
@@ -272,9 +273,9 @@ func isRemote(pkg string) bool {
}
// download checks out or updates pkg from the remote server.
-func download(pkg, srcDir string) (public bool, err os.Error) {
+func download(pkg, srcDir string) (public bool, err error) {
if strings.Contains(pkg, "..") {
- err = os.NewError("invalid path (contains ..)")
+ err = errors.New("invalid path (contains ..)")
return
}
m, err := findPublicRepo(pkg)
@@ -290,7 +291,7 @@ func download(pkg, srcDir string) (public bool, err os.Error) {
}
}
if m == nil {
- err = os.NewError("cannot download: " + pkg)
+ err = errors.New("cannot download: " + pkg)
return
}
err = m.checkoutRepo(srcDir, m.prefix, m.repo)
@@ -300,7 +301,7 @@ func download(pkg, srcDir string) (public bool, err os.Error) {
// updateRepo gets a list of tags in the repository and
// checks out the tag closest to the current runtime.Version.
// If no matching tag is found, it just updates to tip.
-func (v *vcs) updateRepo(dst string) os.Error {
+func (v *vcs) updateRepo(dst string) error {
if v.tagList == "" || v.tagListRe == nil {
// TODO(adg): fix for svn
return run(dst, nil, v.cmd, v.update)
@@ -382,11 +383,11 @@ func selectTag(goVersion string, tags []string) (match string) {
// exists and -u was specified on the command line)
// the repository at tag/branch "release". If there is no
// such tag or branch, it falls back to the repository tip.
-func (vcs *vcs) checkoutRepo(srcDir, pkgprefix, repo string) os.Error {
+func (vcs *vcs) checkoutRepo(srcDir, pkgprefix, repo string) error {
dst := filepath.Join(srcDir, filepath.FromSlash(pkgprefix))
dir, err := os.Stat(filepath.Join(dst, vcs.metadir))
if err == nil && !dir.IsDirectory() {
- return os.NewError("not a directory: " + dst)
+ return errors.New("not a directory: " + dst)
}
if err != nil {
parent, _ := filepath.Split(dst)
diff --git a/src/cmd/goinstall/main.go b/src/cmd/goinstall/main.go
index 91c8ad4f7..431a535f9 100644
--- a/src/cmd/goinstall/main.go
+++ b/src/cmd/goinstall/main.go
@@ -6,6 +6,7 @@ package main
import (
"bytes"
+ "errors"
"exec"
"flag"
"fmt"
@@ -31,7 +32,7 @@ const logfile = "goinstall.log"
var (
fset = token.NewFileSet()
argv0 = os.Args[0]
- errors = false
+ errors_ = false
parents = make(map[string]string)
visit = make(map[string]status)
installedPkgs = make(map[string]map[string]bool)
@@ -67,7 +68,7 @@ func printf(format string, args ...interface{}) {
}
func errorf(format string, args ...interface{}) {
- errors = true
+ errors_ = true
logf(format, args...)
}
@@ -119,7 +120,7 @@ func main() {
install(path, "")
}
- if errors {
+ if errors_ {
os.Exit(1)
}
}
@@ -243,7 +244,7 @@ func install(pkg, parent string) {
install(p, pkg)
}
}
- if errors {
+ if errors_ {
return
}
@@ -304,17 +305,17 @@ func isStandardPath(s string) bool {
// run runs the command cmd in directory dir with standard input stdin.
// If the command fails, run prints the command and output on standard error
// in addition to returning a non-nil os.Error.
-func run(dir string, stdin []byte, cmd ...string) os.Error {
+func run(dir string, stdin []byte, cmd ...string) error {
return genRun(dir, stdin, cmd, false)
}
// quietRun is like run but prints nothing on failure unless -v is used.
-func quietRun(dir string, stdin []byte, cmd ...string) os.Error {
+func quietRun(dir string, stdin []byte, cmd ...string) error {
return genRun(dir, stdin, cmd, true)
}
// genRun implements run and quietRun.
-func genRun(dir string, stdin []byte, arg []string, quiet bool) os.Error {
+func genRun(dir string, stdin []byte, arg []string, quiet bool) error {
cmd := exec.Command(arg[0], arg[1:]...)
cmd.Stdin = bytes.NewBuffer(stdin)
cmd.Dir = dir
@@ -329,7 +330,7 @@ func genRun(dir string, stdin []byte, arg []string, quiet bool) os.Error {
os.Stderr.Write(out)
fmt.Fprintf(os.Stderr, "--- %s\n", err)
}
- return os.NewError("running " + arg[0] + ": " + err.String())
+ return errors.New("running " + arg[0] + ": " + err.Error())
}
return nil
}
diff --git a/src/cmd/goinstall/make.go b/src/cmd/goinstall/make.go
index 7f41a913f..c724cda47 100644
--- a/src/cmd/goinstall/make.go
+++ b/src/cmd/goinstall/make.go
@@ -8,8 +8,8 @@ package main
import (
"bytes"
+ "errors"
"go/build"
- "os"
"path" // use for import paths
"strings"
"template"
@@ -18,7 +18,7 @@ import (
// domake builds the package in dir.
// domake generates a standard Makefile and passes it
// to make on standard input.
-func domake(dir, pkg string, tree *build.Tree, isCmd bool) (err os.Error) {
+func domake(dir, pkg string, tree *build.Tree, isCmd bool) (err error) {
makefile, err := makeMakefile(dir, pkg, tree, isCmd)
if err != nil {
return err
@@ -36,9 +36,9 @@ func domake(dir, pkg string, tree *build.Tree, isCmd bool) (err os.Error) {
// makeMakefile computes the standard Makefile for the directory dir
// installing as package pkg. It includes all *.go files in the directory
// except those in package main and those ending in _test.go.
-func makeMakefile(dir, pkg string, tree *build.Tree, isCmd bool) ([]byte, os.Error) {
+func makeMakefile(dir, pkg string, tree *build.Tree, isCmd bool) ([]byte, error) {
if !safeName(pkg) {
- return nil, os.NewError("unsafe name: " + pkg)
+ return nil, errors.New("unsafe name: " + pkg)
}
targ := pkg
targDir := tree.PkgDir()
@@ -56,7 +56,7 @@ func makeMakefile(dir, pkg string, tree *build.Tree, isCmd bool) ([]byte, os.Err
isCgo := make(map[string]bool, len(cgoFiles))
for _, file := range cgoFiles {
if !safeName(file) {
- return nil, os.NewError("bad name: " + file)
+ return nil, errors.New("bad name: " + file)
}
isCgo[file] = true
}
@@ -64,7 +64,7 @@ func makeMakefile(dir, pkg string, tree *build.Tree, isCmd bool) ([]byte, os.Err
goFiles := make([]string, 0, len(dirInfo.GoFiles))
for _, file := range dirInfo.GoFiles {
if !safeName(file) {
- return nil, os.NewError("unsafe name: " + file)
+ return nil, errors.New("unsafe name: " + file)
}
if !isCgo[file] {
goFiles = append(goFiles, file)
@@ -75,7 +75,7 @@ func makeMakefile(dir, pkg string, tree *build.Tree, isCmd bool) ([]byte, os.Err
cgoOFiles := make([]string, 0, len(dirInfo.CFiles))
for _, file := range dirInfo.CFiles {
if !safeName(file) {
- return nil, os.NewError("unsafe name: " + file)
+ return nil, errors.New("unsafe name: " + file)
}
// When cgo is in use, C files are compiled with gcc,
// otherwise they're compiled with gc.
@@ -88,7 +88,7 @@ func makeMakefile(dir, pkg string, tree *build.Tree, isCmd bool) ([]byte, os.Err
for _, file := range dirInfo.SFiles {
if !safeName(file) {
- return nil, os.NewError("unsafe name: " + file)
+ return nil, errors.New("unsafe name: " + file)
}
oFiles = append(oFiles, file[:len(file)-2]+".$O")
}
diff --git a/src/cmd/gotest/gotest.go b/src/cmd/gotest/gotest.go
index ad350dbf0..9a4d2e916 100644
--- a/src/cmd/gotest/gotest.go
+++ b/src/cmd/gotest/gotest.go
@@ -307,7 +307,7 @@ func doRun(argv []string, returnStdout bool) string {
command = "bash"
argv = []string{"bash", "-c", cmd}
}
- var err os.Error
+ var err error
argv[0], err = exec.LookPath(argv[0])
if err != nil {
Fatalf("can't find %s: %s", command, err)
diff --git a/src/cmd/govet/govet.go b/src/cmd/govet/govet.go
index 98c7fc89b..08b9845b3 100644
--- a/src/cmd/govet/govet.go
+++ b/src/cmd/govet/govet.go
@@ -61,7 +61,7 @@ func main() {
}
skip := 0
if colon := strings.LastIndex(name, ":"); colon > 0 {
- var err os.Error
+ var err error
skip, err = strconv.Atoi(name[colon+1:])
if err != nil {
errorf(`illegal format for "Func:N" argument %q; %s`, name, err)
@@ -105,7 +105,7 @@ func doFile(name string, reader io.Reader) {
file.checkFile(name, parsedFile)
}
-func visit(path string, f *os.FileInfo, err os.Error) os.Error {
+func visit(path string, f *os.FileInfo, err error) error {
if err != nil {
errorf("walk error: %s", err)
return nil
diff --git a/src/cmd/hgpatch/main.go b/src/cmd/hgpatch/main.go
index e072a80d9..ec69340c3 100644
--- a/src/cmd/hgpatch/main.go
+++ b/src/cmd/hgpatch/main.go
@@ -31,7 +31,7 @@ func main() {
args := flag.Args()
var data []byte
- var err os.Error
+ var err error
switch len(args) {
case 0:
data, err = ioutil.ReadAll(os.Stdin)
@@ -189,7 +189,7 @@ func makeParent(name string) {
// Copy of os.MkdirAll but adds to undo log after
// creating a directory.
-func mkdirAll(path string, perm uint32) os.Error {
+func mkdirAll(path string, perm uint32) error {
dir, err := os.Lstat(path)
if err == nil {
if dir.IsDirectory() {
@@ -230,7 +230,7 @@ func mkdirAll(path string, perm uint32) os.Error {
}
// If err != nil, process the undo log and exit.
-func chk(err os.Error) {
+func chk(err error) {
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
runUndo()
@@ -239,15 +239,15 @@ func chk(err os.Error) {
}
// Undo log
-type undo func() os.Error
+type undo func() error
var undoLog []undo
func undoRevert(name string) {
- undoLog = append(undoLog, undo(func() os.Error { return hgRevert(name) }))
+ undoLog = append(undoLog, undo(func() error { return hgRevert(name) }))
}
-func undoRm(name string) { undoLog = append(undoLog, undo(func() os.Error { return os.Remove(name) })) }
+func undoRm(name string) { undoLog = append(undoLog, undo(func() error { return os.Remove(name) })) }
func runUndo() {
for i := len(undoLog) - 1; i >= 0; i-- {
@@ -258,7 +258,7 @@ func runUndo() {
}
// hgRoot returns the root directory of the repository.
-func hgRoot() (string, os.Error) {
+func hgRoot() (string, error) {
out, err := run([]string{"hg", "root"}, nil)
if err != nil {
return "", err
@@ -276,7 +276,7 @@ func hgIncoming() bool {
// hgModified returns a list of the modified files in the
// repository.
-func hgModified() ([]string, os.Error) {
+func hgModified() ([]string, error) {
out, err := run([]string{"hg", "status", "-n"}, nil)
if err != nil {
return nil, err
@@ -285,33 +285,33 @@ func hgModified() ([]string, os.Error) {
}
// hgAdd adds name to the repository.
-func hgAdd(name string) os.Error {
+func hgAdd(name string) error {
_, err := run([]string{"hg", "add", name}, nil)
return err
}
// hgRemove removes name from the repository.
-func hgRemove(name string) os.Error {
+func hgRemove(name string) error {
_, err := run([]string{"hg", "rm", name}, nil)
return err
}
// hgRevert reverts name.
-func hgRevert(name string) os.Error {
+func hgRevert(name string) error {
_, err := run([]string{"hg", "revert", name}, nil)
return err
}
// hgCopy copies src to dst in the repository.
// Note that the argument order matches io.Copy, not "hg cp".
-func hgCopy(dst, src string) os.Error {
+func hgCopy(dst, src string) error {
_, err := run([]string{"hg", "cp", src, dst}, nil)
return err
}
// hgRename renames src to dst in the repository.
// Note that the argument order matches io.Copy, not "hg mv".
-func hgRename(dst, src string) os.Error {
+func hgRename(dst, src string) error {
_, err := run([]string{"hg", "mv", src, dst}, nil)
return err
}
@@ -326,7 +326,7 @@ var lookPathCache = make(map[string]string)
// run runs the command argv, resolving argv[0] if necessary by searching $PATH.
// It provides input on standard input to the command.
-func run(argv []string, input []byte) (out string, err os.Error) {
+func run(argv []string, input []byte) (out string, err error) {
if len(argv) < 1 {
return "", &runError{dup(argv), os.EINVAL}
}
@@ -354,7 +354,7 @@ func run(argv []string, input []byte) (out string, err os.Error) {
// A runError represents an error that occurred while running a command.
type runError struct {
cmd []string
- err os.Error
+ err error
}
-func (e *runError) String() string { return strings.Join(e.cmd, " ") + ": " + e.err.String() }
+func (e *runError) Error() string { return strings.Join(e.cmd, " ") + ": " + e.err.Error() }