diff options
| author | Russ Cox <rsc@golang.org> | 2011-11-01 22:06:05 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2011-11-01 22:06:05 -0400 |
| commit | 44526cdbe0c012c2a9bf6fc493aa8ad3411b884f (patch) | |
| tree | 25afb6c71d7243d18ecd3f74ec6a77fd04fe1871 /src/cmd/goinstall | |
| parent | eb6929299b6da3d9bea1fa7f7cd319c2de9242bb (diff) | |
| download | go-44526cdbe0c012c2a9bf6fc493aa8ad3411b884f.tar.xz | |
non-pkg: gofix -r error -force=error
R=golang-dev, iant, r, r
CC=golang-dev
https://golang.org/cl/5307066
Diffstat (limited to 'src/cmd/goinstall')
| -rw-r--r-- | src/cmd/goinstall/download.go | 35 | ||||
| -rw-r--r-- | src/cmd/goinstall/main.go | 17 | ||||
| -rw-r--r-- | src/cmd/goinstall/make.go | 16 |
3 files changed, 35 insertions, 33 deletions
diff --git a/src/cmd/goinstall/download.go b/src/cmd/goinstall/download.go index 28924c70e4..927970a45b 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 91c8ad4f76..431a535f9b 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 7f41a913f8..c724cda47b 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") } |
