Skip to content

Commit af982ab

Browse files
agnivadeFiloSottile
authored andcommitted
internal/genv: fix release notes link for minor versions
Also corrected the code in case of unrecognized version. According to the docs, nil is returned when the regex does not match. And in case of a partial or full match, the length of the slice is always equal to the no. of subexpressions. For the subexpressions that did not match, the string will be empty. So the length check was logically wrong. It's just that since the length of a nil slice is 0, it accidentally turned out to be correct. Fixes golang/go#26976 Change-Id: Ic9e43d13877d747df20c15949436e355d2fd448d Reviewed-on: https://go-review.googlesource.com/c/160920 Reviewed-by: Filippo Valsorda <[email protected]>
1 parent eb5f367 commit af982ab

File tree

29 files changed

+52
-29
lines changed

29 files changed

+52
-29
lines changed

go1.10.1/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.10.1 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.10
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.10.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.10.2/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.10.2 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.10
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.10.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.10.3/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.10.3 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.10
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.10.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.10.4/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.10.4 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.10
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.10.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.10.5/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.10.5 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.10
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.10.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.10.6/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.10.6 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.10
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.10.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.10.7/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.10.7 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.10
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.10.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.10.8/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.10.8 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.10
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.10.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.11.1/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.11.1 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.11
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.11.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.11.2/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.11.2 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.11
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.11.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.11.3/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.11.3 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.11
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.11.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.11.4/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.11.4 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.11
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.11.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.11.5/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.11.5 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.11
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.11.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.8.1/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.8.1 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.8
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.8.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.8.2/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.8.2 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.8
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.8.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.8.3/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.8.3 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.8
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.8.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.8.4/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.8.4 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.8
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.8.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.8.5/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.8.5 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.8
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.8.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.8.6/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.8.6 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.8
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.8.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.8.7/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.8.7 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.8
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.8.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.9.1/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.9.1 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.9
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.9.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.9.2/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.9.2 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.9
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.9.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.9.3/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.9.3 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.9
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.9.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.9.4/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.9.4 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.9
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.9.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.9.5/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.9.5 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.9
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.9.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.9.6/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.9.6 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.9
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.9.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

go1.9.7/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// And then use the go1.9.7 command as if it were your normal go
1313
// command.
1414
//
15-
// See the release notes at https://golang.org/doc/go1.9
15+
// See the release notes at https://golang.org/doc/devel/release.html#go1.9.minor
1616
//
1717
// File bugs at https://golang.org/issues/new
1818
package main

internal/genv/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@ func docHost(ver string) string {
6969
}
7070

7171
func versionNoPatch(ver string) string {
72-
rx := regexp.MustCompile(`^(go\d+\.\d+)($|rc|beta|\.)`)
72+
rx := regexp.MustCompile(`^(go\d+\.\d+)($|[\.]?\d*)($|rc|beta|\.)`)
7373
m := rx.FindStringSubmatch(ver)
74-
if len(m) < 2 {
74+
if m == nil {
7575
failf("unrecognized version %q", ver)
7676
}
77+
if m[2] != "" {
78+
return "devel/release.html#" + m[1] + ".minor"
79+
}
7780
return m[1]
7881
}
7982

internal/genv/main_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package main
2+
3+
import "testing"
4+
5+
func TestVersionNoPatch(t *testing.T) {
6+
data := []struct {
7+
in string
8+
out string
9+
}{
10+
{"go1.11.4", "devel/release.html#go1.11.minor"},
11+
{"go1.12", "go1.12"},
12+
{"go1.12beta1", "go1.12"},
13+
{"go1.12rc2", "go1.12"},
14+
}
15+
for _, item := range data {
16+
if out := versionNoPatch(item.in); out != item.out {
17+
t.Errorf("versionNoPatch(%q) = %q; want %q", item.in, out, item.out)
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)