]> Cypherpunks repositories - gostls13.git/commitdiff
goinstall: abort and warn when using any url scheme, not just 'http://'
authorAndrew Gerrand <adg@golang.org>
Mon, 25 Jul 2011 18:16:34 +0000 (04:16 +1000)
committerAndrew Gerrand <adg@golang.org>
Mon, 25 Jul 2011 18:16:34 +0000 (04:16 +1000)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4801053

src/cmd/goinstall/main.go

index 7c04208e8c06e6afd9a1af41c8b73c211d123a72..86e490e24a5e441ba09e8319c304afff12edec30 100644 (file)
@@ -14,6 +14,7 @@ import (
        "io/ioutil"
        "os"
        "path/filepath"
+       "regexp"
        "runtime"
        "strings"
 )
@@ -34,6 +35,7 @@ var (
        parents       = make(map[string]string)
        visit         = make(map[string]status)
        installedPkgs = make(map[string]map[string]bool)
+       schemeRe      = regexp.MustCompile(`^[a-z]+://`)
 
        allpkg            = flag.Bool("a", false, "install all previously installed packages")
        reportToDashboard = flag.Bool("dashboard", true, "report public packages at "+dashboardURL)
@@ -103,8 +105,8 @@ func main() {
                usage()
        }
        for _, path := range args {
-               if strings.HasPrefix(path, "http://") {
-                       errorf("'http://' used in remote path, try '%s'\n", path[7:])
+               if s := schemeRe.FindString(path); s != "" {
+                       errorf("%q used in import path, try %q\n", s, path[len(s):])
                        continue
                }