diff --git a/src/cmd/go/internal/modfetch/codehost/vcs.go b/src/cmd/go/internal/modfetch/codehost/vcs.go index b1845f5c65..48238f176c 100644 --- a/src/cmd/go/internal/modfetch/codehost/vcs.go +++ b/src/cmd/go/internal/modfetch/codehost/vcs.go @@ -341,7 +341,9 @@ func (r *vcsRepo) Stat(rev string) (*RevInfo, error) { } func (r *vcsRepo) fetch() { - _, r.fetchErr = Run(r.dir, r.cmd.fetch) + if len(r.cmd.fetch) > 0 { + _, r.fetchErr = Run(r.dir, r.cmd.fetch) + } } func (r *vcsRepo) statLocal(rev string) (*RevInfo, error) { diff --git a/src/cmd/go/testdata/script/mod_get_svn.txt b/src/cmd/go/testdata/script/mod_get_svn.txt index e89bb9d9f5..90be737213 100644 --- a/src/cmd/go/testdata/script/mod_get_svn.txt +++ b/src/cmd/go/testdata/script/mod_get_svn.txt @@ -13,6 +13,12 @@ stderr 'ReadZip not implemented for svn' ! go install . stderr 'ReadZip not implemented for svn' +# Attempting to get a nonexistent module using svn should fail with a +# reasonable message instead of a panic. +! go get -d vcs-test.golang.org/svn/nonexistent.svn +! stderr panic +stderr 'go get vcs-test.golang.org/svn/nonexistent.svn: no matching versions for query "latest"' + -- go.mod -- module golang/go/issues/28943/main -- main.go --