-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/frontend: support displaying multiple of same type
Previously on the versions page, we were not handling the case when different identifiers are added for the same type for different build contexts, and which build context was surfaced was based on chance. To support this case, it is now possible to show multiple of the same type at the same version. For example, https://pkg.go.dev/internal/poll?tab=versions at go1.10 will show: ``` type FD — windows/amd64 + func (fd *FD) ReadMsg(p []byte, oob []byte) (int, int, int, syscall.Sockaddr, error) + func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, error) type FD — darwin/amd64, linux/amd64 + func (fd *FD) SetBlocking() error + func (fd *FD) WriteOnce(p []byte) (int, error) ``` For golang/go#37102 Change-Id: I19e6ef12f1f8f9c412aab7cea2782409eecf29f9 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/317489 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
- Loading branch information
Showing
7 changed files
with
197 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2021 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package frontend | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestCompareStringSlices(t *testing.T) { | ||
a := []string{"a"} | ||
ab := []string{"a", "b"} | ||
ac := []string{"a", "c"} | ||
for _, test := range []struct { | ||
ss1, ss2 []string | ||
want int | ||
}{ | ||
{nil, nil, 0}, | ||
{nil, a, -1}, | ||
{ab, ab, 0}, | ||
{a, ab, -1}, | ||
{ab, ac, -1}, | ||
} { | ||
got := compareStringSlices(test.ss1, test.ss2) | ||
if got != test.want { | ||
t.Fatalf("%v, %v: got %d, want %d\n", test.ss1, test.ss2, got, test.want) | ||
} | ||
if test.want != 0 { | ||
got := compareStringSlices(test.ss2, test.ss1) | ||
want := -test.want | ||
if got != want { | ||
t.Fatalf("%v, %v: got %d, want %d\n", test.ss2, test.ss1, got, want) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters