x/tools/cmd/godoc: add golang.org/x/review custom import path

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/174410043
This commit is contained in:
Andrew Gerrand 2014-11-19 14:03:19 +11:00
parent a3be5384d5
commit 1536a92c03
1 changed files with 22 additions and 15 deletions

View File

@ -17,19 +17,25 @@ import (
const xPrefix = "/x/"
var xMap = map[string]string{
"benchmarks": "https://code.google.com/p/go.benchmarks",
"blog": "https://code.google.com/p/go.blog",
"codereview": "https://code.google.com/p/go.codereview",
"crypto": "https://code.google.com/p/go.crypto",
"exp": "https://code.google.com/p/go.exp",
"image": "https://code.google.com/p/go.image",
"mobile": "https://code.google.com/p/go.mobile",
"net": "https://code.google.com/p/go.net",
"sys": "https://code.google.com/p/go.sys",
"talks": "https://code.google.com/p/go.talks",
"text": "https://code.google.com/p/go.text",
"tools": "https://code.google.com/p/go.tools",
type xRepo struct {
URL, VCS string
}
var xMap = map[string]xRepo{
"benchmarks": {"https://code.google.com/p/go.benchmarks", "hg"},
"blog": {"https://code.google.com/p/go.blog", "hg"},
"codereview": {"https://code.google.com/p/go.codereview", "hg"},
"crypto": {"https://code.google.com/p/go.crypto", "hg"},
"exp": {"https://code.google.com/p/go.exp", "hg"},
"image": {"https://code.google.com/p/go.image", "hg"},
"mobile": {"https://code.google.com/p/go.mobile", "hg"},
"net": {"https://code.google.com/p/go.net", "hg"},
"sys": {"https://code.google.com/p/go.sys", "hg"},
"talks": {"https://code.google.com/p/go.talks", "hg"},
"text": {"https://code.google.com/p/go.text", "hg"},
"tools": {"https://code.google.com/p/go.tools", "hg"},
"review": {"https://go.googlecode.com/review", "git"},
}
func init() {
@ -47,7 +53,8 @@ func xHandler(w http.ResponseWriter, r *http.Request) {
return
}
data := struct {
Prefix, Head, Tail, Repo string
Prefix, Head, Tail string
Repo xRepo
}{xPrefix, head, tail, repo}
if err := xTemplate.Execute(w, data); err != nil {
log.Println("xHandler:", err)
@ -58,7 +65,7 @@ var xTemplate = template.Must(template.New("x").Parse(`<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="go-import" content="golang.org{{.Prefix}}{{.Head}} hg {{.Repo}}">
<meta name="go-import" content="golang.org{{.Prefix}}{{.Head}} {{.Repo.VCS}} {{.Repo.URL}}">
<meta http-equiv="refresh" content="0; url=https://godoc.org/golang.org{{.Prefix}}{{.Head}}{{.Tail}}">
</head>
<body>