diff --git a/godoc/versions.go b/godoc/versions.go index 849f4d6470c..5a4dec33ea1 100644 --- a/godoc/versions.go +++ b/godoc/versions.go @@ -189,7 +189,7 @@ func parseRow(s string) (vr versionedRow, ok bool) { case strings.HasPrefix(rest, "func "): vr.kind = "func" rest = rest[len("func "):] - if i := strings.IndexByte(rest, '('); i != -1 { + if i := strings.IndexAny(rest, "[("); i != -1 { vr.name = rest[:i] return vr, true } diff --git a/godoc/versions_test.go b/godoc/versions_test.go index 0c5ca50c774..a021616ba11 100644 --- a/godoc/versions_test.go +++ b/godoc/versions_test.go @@ -65,6 +65,27 @@ func TestParseVersionRow(t *testing.T) { recv: "Encoding", }, }, + { + // Function with type parameters. + // Taken from "go/src/api/go1.21.txt". + row: "pkg cmp, func Compare[$0 Ordered]($0, $0) int #59488", + want: versionedRow{ + pkg: "cmp", + kind: "func", + name: "Compare", + }, + }, + { + // Function without type parameter but have "[" after + // "(" should have works as is. + // Taken from "go/src/api/go1.21.txt". + row: "pkg bytes, func ContainsFunc([]uint8, func(int32) bool) bool #54386", + want: versionedRow{ + pkg: "bytes", + kind: "func", + name: "ContainsFunc", + }, + }, } for i, tt := range tests {