gosrc: Fix broken Package Files link.

CL https://golang.org/cl/24513 removed {tag} element from browseURL,
which causes the generated Package Files links to be 404.

Add the {tag} element back, use default branch of the repository.
There is no logic to handle "go1" special case, but neither does
the rest of the logic in getGitHubDir. The scope of this CL is to
fix the broken link only.

Fixes golang/gddo#484.

Change-Id: I34d3c49c0efd98351297272cb41f7a65e1dd47b5
Reviewed-on: https://go-review.googlesource.com/40499
Reviewed-by: Tuo Shan <shantuo@google.com>
diff --git a/gosrc/github.go b/gosrc/github.go
index c1818ee..a96cf92 100644
--- a/gosrc/github.go
+++ b/gosrc/github.go
@@ -62,10 +62,11 @@
 	c := &httpClient{client: client, errFn: gitHubError}
 
 	var repo struct {
-		Fork      bool      `json:"fork"`
-		Stars     int       `json:"stargazers_count"`
-		CreatedAt time.Time `json:"created_at"`
-		PushedAt  time.Time `json:"pushed_at"`
+		Fork          bool      `json:"fork"`
+		Stars         int       `json:"stargazers_count"`
+		CreatedAt     time.Time `json:"created_at"`
+		PushedAt      time.Time `json:"pushed_at"`
+		DefaultBranch string    `json:"default_branch"`
 	}
 
 	if _, err := c.getJSON(expand("https://api.github.com/repos/{owner}/{repo}", match), &repo); err != nil {
@@ -158,7 +159,8 @@
 
 	browseURL := expand("https://github.com/{owner}/{repo}", match)
 	if match["dir"] != "" {
-		browseURL = expand("https://github.com/{owner}/{repo}/tree{dir}", match)
+		match["tag"] = repo.DefaultBranch // TODO: This doesn't respect "go1" tag/branch special case.
+		browseURL = expand("https://github.com/{owner}/{repo}/tree/{tag}{dir}", match)
 	}
 
 	return &Directory{