From 327197e6b056fd5c2c733feceab7a7a195556dbc Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Tue, 3 Apr 2018 11:52:19 +0530 Subject: [PATCH] godoc,blog: perform minor cleanup - Remove a stray comment which was no longer needed. The accompanying issue golang.org/issue/7524 was discussed and closed. - Combine 2 if conditions into a single if-else because length of a slice can never be negative. - Remove http links from golangOrgAbsLinkReplacer now that all links have been changed to https in the blog articles. Change-Id: I2fe2ec245b580a91760c9331e9626b367f1b6740 Reviewed-on: https://go-review.googlesource.com/107155 Run-TryBot: Brad Fitzpatrick Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- blog/blog.go | 3 --- blog/blog_test.go | 4 ++-- godoc/index.go | 1 - godoc/server.go | 5 +---- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/blog/blog.go b/blog/blog.go index c26b6adbcb..73c184d4b4 100644 --- a/blog/blog.go +++ b/blog/blog.go @@ -27,11 +27,8 @@ import ( var ( validJSONPFunc = regexp.MustCompile(`(?i)^[a-z_][a-z0-9_.]*$`) // used to serve relative paths when ServeLocalLinks is enabled. - // TODO(agnivade): change blog article links to all have https. golangOrgAbsLinkReplacer = strings.NewReplacer( - `href="http://golang.org/pkg`, `href="/pkg`, `href="https://golang.org/pkg`, `href="/pkg`, - `href="http://golang.org/cmd`, `href="/cmd`, `href="https://golang.org/cmd`, `href="/cmd`, ) ) diff --git a/blog/blog_test.go b/blog/blog_test.go index 90155feadc..c84be2a716 100644 --- a/blog/blog_test.go +++ b/blog/blog_test.go @@ -15,10 +15,10 @@ func TestLinkRewrite(t *testing.T) { output string }{ { - `For instance, the bytes package from the standard library exports the Buffer type.`, + `For instance, the bytes package from the standard library exports the Buffer type.`, `For instance, the bytes package from the standard library exports the Buffer type.`}, { - `(The gofmt command has a -r flag that provides a syntax-aware search and replace, making large-scale refactoring easier.)`, + `(The gofmt command has a -r flag that provides a syntax-aware search and replace, making large-scale refactoring easier.)`, `(The gofmt command has a -r flag that provides a syntax-aware search and replace, making large-scale refactoring easier.)`, }, { diff --git a/godoc/index.go b/godoc/index.go index 8cefd1423d..c9b9bd338e 100644 --- a/godoc/index.go +++ b/godoc/index.go @@ -1532,7 +1532,6 @@ func (c *Corpus) RunIndexer() { } // Repeatedly update the package directory tree and index. - // TODO(bgarcia): Use fsnotify to only update when notified of a filesystem change. for { c.initFSTree() c.UpdateIndex() diff --git a/godoc/server.go b/godoc/server.go index 9240746d00..3e271bdd6c 100644 --- a/godoc/server.go +++ b/godoc/server.go @@ -113,10 +113,7 @@ func (h *handlerServer) GetPageInfo(abspath, relpath string, mode PageInfoMode, // documentation (historic). pkgname = "main" // assume package main since pkginfo.Name == "" pkgfiles = pkginfo.IgnoredGoFiles - } - - // get package information, if any - if len(pkgfiles) > 0 { + } else { // build package AST fset := token.NewFileSet() files, err := h.c.parseFiles(fset, relpath, abspath, pkgfiles)