Compare commits

...

15 Commits

Author SHA1 Message Date
Rebecca Stambler e7e52e73e2 [release-branch.go1.10] godoc/static: update copyright year in static.go
This change was created with `go generate
golang.org/x/tools/godoc/static` and updates the year in the copyright
notice in the file.

Change-Id: I5916b7a6d1f1ceae84d58c392767ca97b314ebc3
Reviewed-on: https://go-review.googlesource.com/c/156077
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit 7c850e7ac1)
Reviewed-on: https://go-review.googlesource.com/c/156340
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-04 18:27:19 +00:00
Brad Fitzpatrick 156d532d4f [release-branch.go1.10] godoc/dl: update Mac & Windows minimum versions
Updates golang/go#27213

Change-Id: I25813e9aafcdb39d4f93e27b98d8672c770234a6
Reviewed-on: https://go-review.googlesource.com/131402
Reviewed-by: Andrew Bonventre <andybons@golang.org>
(cherry picked from commit 1057b4d08146b510c47b87a2221e9720fe1a9fb9)
Reviewed-on: https://go-review.googlesource.com/131403
2018-08-26 16:47:53 +00:00
Robert Griesemer 8cc6a32d9b [release-branch.go1.10] godoc: fix test failure
Adjust code to satisfy vet.

Change-Id: I532b4d988eb29b413520de60b8520d9e100b42c9
Reviewed-on: https://go-review.googlesource.com/118557
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(cherry picked from commit 02fcd6aaf1)
Reviewed-on: https://go-review.googlesource.com/126835
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-31 19:39:58 +00:00
Andrew Bonventre 0d7f9d6ece [release-branch.go1.10] godoc: don't display tar instructions for malformed download query
Ensure that the filename passed via ?download= matches the given
regexp before showing the command-line instructions to download it.

Change-Id: I87d734ebeb1f5e8e1b4311a8be6b3ae18bef8b10
Reviewed-on: https://go-review.googlesource.com/126798
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-30 22:30:05 +00:00
Brad Fitzpatrick be728107ea [release-branch.go1.10] godoc/dl: also serve go-import meta tags at golang.org/dl for cmd/go
Updates golang/go#23223

Change-Id: Iacecbb5e095fd3d6acb3f8e1fb238db63d1e0b6d
Reviewed-on: https://go-review.googlesource.com/125195
Reviewed-by: Andrew Bonventre <andybons@golang.org>
(cherry picked from commit 99195f4d4f)
Reviewed-on: https://go-review.googlesource.com/125176
2018-07-20 16:20:53 +00:00
Andrew Bonventre d1fff0794f [release-branch.go1.10] godoc/dl: update download link from /x/build/version to /dl
Change-Id: Id2baaa87ab23e27ce5018271c8bb4e73750fb437
Reviewed-on: https://go-review.googlesource.com/125137
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(cherry picked from commit b1e472a6fcaf6cd39293984c1d101cb1f4b9e7cd)
Reviewed-on: https://go-review.googlesource.com/125155
2018-07-20 03:36:27 +00:00
Brad Fitzpatrick 42933c415e [release-branch.go1.10] godoc/dl: add meta tags for go get golang.org/dl/go1.N
Updates golang/go#23223

Change-Id: I628cea181d3a0e6bb25fdd98e098581aa222e049
Reviewed-on: https://go-review.googlesource.com/123679
Reviewed-by: Andrew Bonventre <andybons@golang.org>
(cherry picked from commit 827f47db85)
Reviewed-on: https://go-review.googlesource.com/125175
2018-07-20 03:36:06 +00:00
Filippo Valsorda e9928cbe4a [release-branch.go1.10] godoc/dl: add valsorda to users allowed to upload
Change-Id: Iac4a80b030be9c275323a27d2dfba4f83942cbf9
Reviewed-on: https://go-review.googlesource.com/117195
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(cherry picked from commit 4e38c85762)
Reviewed-on: https://go-review.googlesource.com/117215
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-06-07 19:00:54 +00:00
Andrew Bonventre d3e4ceb59d [release-branch.go1.10] godoc: don't exclude version field from File struct
When uploading a new release, it deserializes the payload into
a File struct for processing. It needs the Version field to
determine which release it's in.

Change-Id: I171f416dbb1b1b6c354948ea9a31b9c8694f892e
Reviewed-on: https://go-review.googlesource.com/110627
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
(cherry picked from commit 7d1093680e1fd99c46025161a45e7f5230c79d60)
Reviewed-on: https://go-review.googlesource.com/110635
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-01 16:38:31 +00:00
Andrew Bonventre 97530abbb5 [release-branch.go1.10] cmd/godoc: add x/lint and x/vgo redirects
Update golang/go#25048

Change-Id: I6e21f167091338600c2a0a37411b0a565d27ce36
Reviewed-on: https://go-review.googlesource.com/96196
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit 733d489786)
Reviewed-on: https://go-review.googlesource.com/109095
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-04-24 16:22:42 +00:00
Zachary Gershman bd7f39a7ac [release-branch.go1.10] godoc/dl: provide JSON feed of releases
This addresses the build errors that caused a
revert of the original PR golang/tools#21

Fixes golang/go#23746

GitHub-Last-Rev: 6606c0b63afb4f1043b2aa2dc640edda4cf9afe8
GitHub-Pull-Request: golang/tools#25
Change-Id: Ic5a7e3054d182dc2041d2966ca68960c3abd7620
Reviewed-on: https://go-review.googlesource.com/96178
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(cherry picked from commit 86e0f6745d)
Reviewed-on: https://go-review.googlesource.com/102795
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-03-28 02:06:43 +00:00
Yury Smolsky 27eedfbdea [release-branch.go1.10] cmd/godoc: fix TestWebIndex test
The godoc in the test was indexing sources in the default GOPATH.
If the default GOPATH pointed to local workspace, test would timeout.
The fix is to supply GOPATH set to non-existing path.

Fixes golang/go#24504

Change-Id: Iedf044cdec78d5c5642105650ad8ec17aa10a5ba
Reviewed-on: https://go-review.googlesource.com/102295
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit 77106db15f)
Reviewed-on: https://go-review.googlesource.com/102796
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-03-28 02:06:15 +00:00
Agniva De Sarker 1396c68d3b [release-branch.go1.10] godoc: init corpus in a separate goroutine in http mode
Currently, in http mode the server blocks until the corpus
has been initialized. This can cause considerable delay
if the user workspace is significantly large and the files
are not present in the buffer cache.

This CL spawns off the initialization in a separate goroutine
if httpMode is set and turns on a flag when it's done.
The http handler checks the flag and returns an error response
if it has not been set.

The check is only performed for the path prefixes handled by the
handlerServer struct. Other paths do not call the GetPageInfo() function
and hence can return immediately. This preserves maximum responsiveness
of the server.

Also adds an additional print statement in verbose mode

Note: This is a re-do of a previous CL golang.org/cl/88695 which was
incorrect committed without running tests. This CL fixes that test.

Fixes golang/go#13278

Change-Id: I80c801f32af007312090d3783a2ea2c6f92cad66
Reviewed-on: https://go-review.googlesource.com/93215
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(cherry picked from commit 006ac430a0)
Reviewed-on: https://go-review.googlesource.com/102799
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-03-27 23:32:53 +00:00
Andrew Bonventre c1ca329f65 [release-branch.go1.10] Revert "godoc: init corpus in a separate goroutine in http mode"
This reverts commit f86b507a7e.

Reason for revert: broke tests in tools repo

Change-Id: Id7e5d8e050896b6f5fedaee705be8a5f9adf4bf3
Reviewed-on: https://go-review.googlesource.com/93115
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
(cherry picked from commit 70252dea49)
Reviewed-on: https://go-review.googlesource.com/102797
2018-03-27 23:26:22 +00:00
Robert Griesemer 4c772e4117 [release-branch.go1.10] cmd/guru: fix .golden file (fix build)
This regression is due to https://go-review.googlesource.com/c/go/+/100235
which made the go/scanner behavior match the compiler's scanner by
not modifying filenames in line directives in any form. Specifically,
relative filenames now remain relative. This makes it easier to reason
about the behavior of the scanner but may require clients to adjust
those filenames.

If removing the longer path in the .golden file is not satisfactory,
the (scanner) client may have to massage positions returned via line
directives; or better, the line directives are created with extended
path information.

R=​adonovan

Change-Id: I836571a6dafef5e6d81e4c7add203c994e107055
Reviewed-on: https://go-review.googlesource.com/101015
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit c4b4e4b0fa)
Reviewed-on: https://go-review.googlesource.com/102798
Run-TryBot: Andrew Bonventre <andybons@golang.org>
2018-03-27 23:26:09 +00:00
9 changed files with 120 additions and 58 deletions

View File

@ -154,19 +154,32 @@ func waitForServerReady(t *testing.T, addr string) {
waitForServer(t,
fmt.Sprintf("http://%v/", addr),
"The Go Programming Language",
15*time.Second)
15*time.Second,
false)
}
func waitForSearchReady(t *testing.T, addr string) {
waitForServer(t,
fmt.Sprintf("http://%v/search?q=FALLTHROUGH", addr),
"The list of tokens.",
2*time.Minute)
2*time.Minute,
false)
}
func waitUntilScanComplete(t *testing.T, addr string) {
waitForServer(t,
fmt.Sprintf("http://%v/pkg", addr),
"Scan is not yet complete",
2*time.Minute,
true,
)
// setting reverse as true, which means this waits
// until the string is not returned in the response anymore
}
const pollInterval = 200 * time.Millisecond
func waitForServer(t *testing.T, url, match string, timeout time.Duration) {
func waitForServer(t *testing.T, url, match string, timeout time.Duration, reverse bool) {
// "health check" duplicated from x/tools/cmd/tipgodoc/tip.go
deadline := time.Now().Add(timeout)
for time.Now().Before(deadline) {
@ -177,9 +190,13 @@ func waitForServer(t *testing.T, url, match string, timeout time.Duration) {
}
rbody, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err == nil && res.StatusCode == http.StatusOK &&
bytes.Contains(rbody, []byte(match)) {
return
if err == nil && res.StatusCode == http.StatusOK {
if bytes.Contains(rbody, []byte(match)) && !reverse {
return
}
if !bytes.Contains(rbody, []byte(match)) && reverse {
return
}
}
}
t.Fatalf("Server failed to respond in %v", timeout)
@ -219,7 +236,12 @@ func testWeb(t *testing.T, withIndex bool) {
cmd.Stdout = os.Stderr
cmd.Stderr = os.Stderr
cmd.Args[0] = "godoc"
cmd.Env = godocEnv()
// Set GOPATH variable to non-existing path.
// We cannot just unset GOPATH variable because godoc would default it to ~/go.
// (We don't want the indexer looking at the local workspace during tests.)
cmd.Env = append(os.Environ(), "GOPATH=does_not_exist")
if err := cmd.Start(); err != nil {
t.Fatalf("failed to start godoc: %s", err)
}
@ -229,6 +251,7 @@ func testWeb(t *testing.T, withIndex bool) {
waitForSearchReady(t, addr)
} else {
waitForServerReady(t, addr)
waitUntilScanComplete(t, addr)
}
tests := []struct {
@ -372,14 +395,9 @@ func main() { print(lib.V) }
defer cleanup()
addr := serverAddress(t)
cmd := exec.Command(bin, fmt.Sprintf("-http=%s", addr), "-analysis=type")
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, fmt.Sprintf("GOROOT=%s", filepath.Join(tmpdir, "goroot")))
cmd.Env = append(cmd.Env, fmt.Sprintf("GOPATH=%s", filepath.Join(tmpdir, "gopath")))
for _, e := range os.Environ() {
if strings.HasPrefix(e, "GOROOT=") || strings.HasPrefix(e, "GOPATH=") {
continue
}
cmd.Env = append(cmd.Env, e)
}
cmd.Stdout = os.Stderr
stderr, err := cmd.StderrPipe()
if err != nil {
@ -457,15 +475,3 @@ tryagain:
}
}
}
// godocEnv returns the process environment without the GOPATH variable.
// (We don't want the indexer looking at the local workspace during tests.)
func godocEnv() (env []string) {
for _, v := range os.Environ() {
if strings.HasPrefix(v, "GOPATH=") {
continue
}
env = append(env, v)
}
return
}

View File

@ -333,7 +333,7 @@ func main() {
// Start http server.
if *verbose {
log.Println("starting http server")
log.Println("starting HTTP server")
}
if err := http.ListenAndServe(*httpAddr, handler); err != nil {
log.Fatalf("ListenAndServe %s: %v", *httpAddr, err)

View File

@ -32,6 +32,7 @@ var xMap = map[string]xRepo{
"debug": {"https://go.googlesource.com/debug", "git"},
"exp": {"https://go.googlesource.com/exp", "git"},
"image": {"https://go.googlesource.com/image", "git"},
"lint": {"https://go.googlesource.com/lint", "git"},
"mobile": {"https://go.googlesource.com/mobile", "git"},
"net": {"https://go.googlesource.com/net", "git"},
"oauth2": {"https://go.googlesource.com/oauth2", "git"},
@ -46,6 +47,7 @@ var xMap = map[string]xRepo{
"time": {"https://go.googlesource.com/time", "git"},
"tools": {"https://go.googlesource.com/tools", "git"},
"tour": {"https://go.googlesource.com/tour", "git"},
"vgo": {"https://go.googlesource.com/vgo", "git"},
}
func init() {

View File

@ -56,5 +56,5 @@ references to field f int
-------- @referrers ref-type-U --------
references to type U int
open testdata/src/referrers/nosuchfile.y: no such file or directory (+ 1 more refs in this file)
open nosuchfile.y: no such file or directory (+ 1 more refs in this file)

View File

@ -16,6 +16,7 @@ import (
"crypto/md5"
"encoding/json"
"fmt"
"html"
"html/template"
"io"
"net/http"
@ -27,7 +28,6 @@ import (
"time"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
"google.golang.org/appengine/log"
@ -41,22 +41,24 @@ const (
)
func RegisterHandlers(mux *http.ServeMux) {
mux.Handle("/dl", http.RedirectHandler("/dl/", http.StatusFound))
mux.HandleFunc("/dl", getHandler)
mux.HandleFunc("/dl/", getHandler) // also serves listHandler
mux.HandleFunc("/dl/upload", uploadHandler)
mux.HandleFunc("/dl/init", initHandler)
}
// File represents a file on the golang.org downloads page.
// It should be kept in sync with the upload code in x/build/cmd/release.
type File struct {
Filename string
OS string
Arch string
Version string
Checksum string `datastore:",noindex"` // SHA1; deprecated
ChecksumSHA256 string `datastore:",noindex"`
Size int64 `datastore:",noindex"`
Kind string // "archive", "installer", "source"
Uploaded time.Time
Filename string `json:"filename"`
OS string `json:"os"`
Arch string `json:"arch"`
Version string `json:"version"`
Checksum string `json:"-" datastore:",noindex"` // SHA1; deprecated
ChecksumSHA256 string `json:"sha256" datastore:",noindex"`
Size int64 `json:"size" datastore:",noindex"`
Kind string `json:"kind"` // "archive", "installer", "source"
Uploaded time.Time `json:"-"`
}
func (f File) ChecksumType() string {
@ -137,11 +139,11 @@ func (f File) URL() string {
}
type Release struct {
Version string
Stable bool
Files []File
Visible bool // show files on page load
SplitPortTable bool // whether files should be split by primary/other ports.
Version string `json:"version"`
Stable bool `json:"stable"`
Files []File `json:"files"`
Visible bool `json:"-"` // show files on page load
SplitPortTable bool `json:"-"` // whether files should be split by primary/other ports.
}
type Feature struct {
@ -159,12 +161,12 @@ type Feature struct {
var featuredFiles = []Feature{
{
Platform: "Microsoft Windows",
Requirements: "Windows XP SP3 or later, Intel 64-bit processor",
Requirements: "Windows 7 or later, Intel 64-bit processor",
fileRE: regexp.MustCompile(`\.windows-amd64\.msi$`),
},
{
Platform: "Apple macOS",
Requirements: "macOS 10.8 or later, Intel 64-bit processor",
Requirements: "macOS 10.10 or later, Intel 64-bit processor",
fileRE: regexp.MustCompile(`\.darwin-amd64(-osx10\.8)?\.pkg$`),
},
{
@ -221,6 +223,17 @@ func listHandler(w http.ResponseWriter, r *http.Request) {
log.Errorf(c, "cache set error: %v", err)
}
}
if r.URL.Query().Get("mode") == "json" {
w.Header().Set("Content-Type", "application/json")
enc := json.NewEncoder(w)
enc.SetIndent("", " ")
if err := enc.Encode(d.Stable); err != nil {
log.Errorf(c, "failed rendering JSON for releases: %v", err)
}
return
}
if err := listTemplate.ExecuteTemplate(w, "root", d); err != nil {
log.Errorf(c, "error executing template: %v", err)
}
@ -415,21 +428,59 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
}
func getHandler(w http.ResponseWriter, r *http.Request) {
// For go get golang.org/dl/go1.x.y, we need to serve the
// same meta tags at /dl for cmd/go to validate against /dl/go1.x.y:
if r.URL.Path == "/dl" && (r.Method == "GET" || r.Method == "HEAD") && r.FormValue("go-get") == "1" {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintf(w, `<!DOCTYPE html><html><head>
<meta name="go-import" content="golang.org/dl git https://go.googlesource.com/dl">
</head></html>`)
return
}
if r.URL.Path == "/dl" {
http.Redirect(w, r, "/dl/", http.StatusFound)
return
}
name := strings.TrimPrefix(r.URL.Path, "/dl/")
if name == "" {
listHandler(w, r)
return
}
if !fileRe.MatchString(name) {
http.NotFound(w, r)
if fileRe.MatchString(name) {
http.Redirect(w, r, downloadBaseURL+name, http.StatusFound)
return
}
http.Redirect(w, r, downloadBaseURL+name, http.StatusFound)
if goGetRe.MatchString(name) {
var isGoGet bool
if r.Method == "GET" || r.Method == "HEAD" {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
isGoGet = r.FormValue("go-get") == "1"
}
if !isGoGet {
w.Header().Set("Location", "https://golang.org/dl/#"+name)
w.WriteHeader(http.StatusFound)
}
fmt.Fprintf(w, `<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="go-import" content="golang.org/dl git https://go.googlesource.com/dl">
<meta http-equiv="refresh" content="0; url=https://golang.org/dl/#%s">
</head>
<body>
Nothing to see here; <a href="https://golang.org/dl/#%s">move along</a>.
</body>
</html>
`, html.EscapeString(name), html.EscapeString(name))
return
}
http.NotFound(w, r)
}
func validUser(user string) bool {
switch user {
case "adg", "bradfitz", "cbro", "andybons":
case "adg", "bradfitz", "cbro", "andybons", "valsorda":
return true
}
return false
@ -441,7 +492,10 @@ func userKey(c context.Context, user string) string {
return fmt.Sprintf("%x", h.Sum(nil))
}
var fileRe = regexp.MustCompile(`^go[0-9a-z.]+\.[0-9a-z.-]+\.(tar\.gz|pkg|msi|zip)$`)
var (
fileRe = regexp.MustCompile(`^go[0-9a-z.]+\.[0-9a-z.-]+\.(tar\.gz|pkg|msi|zip)$`)
goGetRe = regexp.MustCompile(`^go[0-9a-z.]+\.[0-9a-z.-]+$`)
)
func initHandler(w http.ResponseWriter, r *http.Request) {
var fileRoot struct {

View File

@ -220,7 +220,7 @@ $(document).ready(function() {
<p>This is an <b>unstable</b> version of Go. Use with caution.</p>
<p>If you already have Go installed, you can install this version by running:</p>
<pre>
go get golang.org/x/build/version/{{.Version}}
go get golang.org/dl/{{.Version}}
</pre>
<p>Then, use the <code>{{.Version}}</code> command instead of the <code>go</code> command to use {{.Version}}.</p>
{{end}}

View File

@ -253,13 +253,13 @@ function personalizeInstallInstructions() {
var filename = s.substr(prefix.length);
var filenameRE = /^go1\.\d+(\.\d+)?([a-z0-9]+)?\.([a-z0-9]+)(-[a-z0-9]+)?(-osx10\.[68])?\.([a-z.]+)$/;
$('.downloadFilename').text(filename);
$('.hideFromDownload').hide();
var m = filenameRE.exec(filename);
if (!m) {
// Can't interpret file name; bail.
return;
}
$('.downloadFilename').text(filename);
$('.hideFromDownload').hide();
var os = m[3];
var ext = m[6];

File diff suppressed because one or more lines are too long

View File

@ -90,7 +90,7 @@ func (p *Presentation) code(file string, arg ...interface{}) (s string, err erro
command = fmt.Sprintf("code %q %s %s", file, stringFor(arg[0]), stringFor(arg[1]))
text = p.Corpus.multipleLines(file, text, arg[0], arg[1])
default:
return "", fmt.Errorf("incorrect code invocation: code %q %q", file, arg)
return "", fmt.Errorf("incorrect code invocation: code %q [%v, ...] (%d arguments)", file, arg[0], len(arg))
}
// Trim spaces from output.
text = strings.Trim(text, "\n")