gosrc: update Go version regexp for golang.org pages
The golang.org website has changed its UI design, and no longer
includes "Build version <version>" text at the bottom of each page.
The build version is still specified on each page in a short script.
Use that instead.
Updates golang/gddo#644
Change-Id: Iedac4fa1f44510af6462f9bb3431c5c23eaaed16
Reviewed-on: https://go-review.googlesource.com/c/gddo/+/193258
Reviewed-by: Tuo Shan <shantuo@google.com>
diff --git a/gosrc/golang.go b/gosrc/golang.go
index d075349..4388fd4 100644
--- a/gosrc/golang.go
+++ b/gosrc/golang.go
@@ -15,7 +15,7 @@
)
var (
- golangBuildVersionRe = regexp.MustCompile(`Build version ([-+:. 0-9A-Za-z]+)`)
+ golangBuildVersionRe = regexp.MustCompile(`var goVersion = "([-+:. 0-9A-Za-z]+)";`)
golangFileRe = regexp.MustCompile(`<a href="([^"]+)"`)
)
@@ -30,7 +30,7 @@
var etag string
m := golangBuildVersionRe.FindSubmatch(p)
- if m == nil {
+ if len(m) < 2 {
return nil, errors.New("Could not find revision for " + importPath)
}
etag = strings.Trim(string(m[1]), ". ")