gddo-server: revert "hide internal packages"

This reverts commit 9b12a26f3fbd7397dee4e20939ddca719d840d2a (CL 90855).

CL 90855 applied a change to fix issue golang/gddo#402, but caused a
regression golang/gddo#533. The regression led to an earlier version
of gddo to be redeployed.

There was an attempt to resolve issue golang/gddo#533 in CL 93196,
which was later picked up and resent as CL 130496.

Tuo and I reviewed CL 130496 and its behavior, and found that
it was not a satisfactory resolution. It introduced additional
complexity and was better in some contexts and situations, but
worse in others. The main downside is that it made it less clear
why some internal packages were being hidden in some places but
not other places.

To fully resolve the original golang/gddo#402, we will need to
come up with and evaluate a more complete plan of action. Until
then, we want to restore the source code to a state which can be
deployed, so take the short term action of reverting the original
CL and go back to a simple and functional behavior: always display
all packages.

Updates golang/gddo#402.
Fixes golang/gddo#533.

Change-Id: I8fb6ac05aa6f118e740e27eaec1bcf2fc9d32766
Reviewed-on: https://go-review.googlesource.com/130937
Reviewed-by: Tuo Shan <shantuo@google.com>
diff --git a/gddo-server/main.go b/gddo-server/main.go
index 2137cb9..635c641 100644
--- a/gddo-server/main.go
+++ b/gddo-server/main.go
@@ -410,7 +410,7 @@
 
 		return s.templates.execute(resp, template, status, http.Header{"Etag": {etag}}, map[string]interface{}{
 			"flashMessages": flashMessages,
-			"pkgs":          removeInternal(pdoc, pkgs),
+			"pkgs":          pkgs,
 			"pdoc":          newTDoc(s.v, pdoc),
 			"importerCount": importerCount,
 		})
@@ -1019,28 +1019,3 @@
 	http.Handle("/", s)
 	log.Fatal(http.ListenAndServe(s.v.GetString(ConfigBindAddress), s))
 }
-
-// removeInternal removes the internal packages from the given package
-// listing unless they are direct children of the given pdoc.
-// Packages filtered by this function will only list internal packages
-// underneath their own package godoc.
-func removeInternal(pdoc *doc.Package, pkgs []database.Package) []database.Package {
-	const internalPkg = "internal"
-
-	if len(pkgs) == 0 {
-		return pkgs
-	}
-	var filtered []database.Package
-	for _, pkg := range pkgs {
-		// List internal packages only under their parent package.
-		// Always list children of the internal packages if user
-		// is looking at the internal godoc.
-		if pdoc.Name != internalPkg && strings.Contains(pkg.Path, internalPkg) {
-			if !strings.HasPrefix(pkg.Path, pdoc.ImportPath+"/"+internalPkg) {
-				continue
-			}
-		}
-		filtered = append(filtered, pkg)
-	}
-	return filtered
-}
diff --git a/gddo-server/main_test.go b/gddo-server/main_test.go
index 6d42906..7c4bc78 100644
--- a/gddo-server/main_test.go
+++ b/gddo-server/main_test.go
@@ -7,11 +7,7 @@
 package main
 
 import (
-	"reflect"
 	"testing"
-
-	"github.com/golang/gddo/database"
-	"github.com/golang/gddo/doc"
 )
 
 var robotTests = []string{
@@ -37,77 +33,3 @@
 		}
 	}
 }
-
-func TestRemoveInternalPkgs(t *testing.T) {
-	tests := []struct {
-		name string
-		pdoc *doc.Package
-		pkgs []database.Package
-		want []database.Package
-	}{
-		{
-			name: "no children",
-			pdoc: &doc.Package{
-				ImportPath: "github.com/user/repo",
-				Name:       "repo",
-			},
-			pkgs: []database.Package{},
-			want: []database.Package{},
-		},
-		{
-			name: "indirect internal children",
-			pdoc: &doc.Package{
-				ImportPath: "github.com/user/repo",
-				Name:       "repo",
-			},
-			pkgs: []database.Package{
-				{Name: "agent", Path: "github.com/user/repo/cmd/internal/agent"},
-				{Name: "agent", Path: "github.com/user/repo/cmd/internal/reporter"},
-				{Name: "tool", Path: "github.com/user/repo/cmd/tool"},
-			},
-			want: []database.Package{
-				{Name: "tool", Path: "github.com/user/repo/cmd/tool"},
-			},
-		},
-		{
-			name: "direct internal children",
-			pdoc: &doc.Package{
-				ImportPath: "github.com/user/repo",
-				Name:       "repo",
-			},
-			pkgs: []database.Package{
-				{Name: "agent", Path: "github.com/user/repo/internal/agent"},
-				{Name: "agent", Path: "github.com/user/repo/internal/reporter"},
-				{Name: "tool", Path: "github.com/user/repo/cmd/tool"},
-			},
-			want: []database.Package{
-				{Name: "agent", Path: "github.com/user/repo/internal/agent"},
-				{Name: "agent", Path: "github.com/user/repo/internal/reporter"},
-				{Name: "tool", Path: "github.com/user/repo/cmd/tool"},
-			},
-		},
-		{
-			name: "internal package",
-			pdoc: &doc.Package{
-				ImportPath: "github.com/user/repo/internal",
-				Name:       "internal",
-			},
-			pkgs: []database.Package{
-				{Name: "agent", Path: "github.com/user/repo/internal/agent"},
-				{Name: "tool", Path: "github.com/user/repo/internal/tool"},
-			},
-			want: []database.Package{
-				{Name: "agent", Path: "github.com/user/repo/internal/agent"},
-				{Name: "tool", Path: "github.com/user/repo/internal/tool"},
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			got, want := removeInternal(tt.pdoc, tt.pkgs), tt.want
-			if !reflect.DeepEqual(got, want) {
-				t.Errorf("removeInternal() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}