1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
Description: Disable embedding static files into binaries
This path is debian-specific, hence this patch cannot go upstream.
Author: MartÃn Ferrari <tincho@debian.org>
Last-Updated: 2016-10-31
Forwarded: no
---
--- a/cmd/godoc/main.go
+++ b/cmd/godoc/main.go
@@ -46,10 +46,8 @@
"golang.org/x/tools/godoc"
"golang.org/x/tools/godoc/analysis"
- "golang.org/x/tools/godoc/static"
"golang.org/x/tools/godoc/vfs"
"golang.org/x/tools/godoc/vfs/gatefs"
- "golang.org/x/tools/godoc/vfs/mapfs"
"golang.org/x/tools/godoc/vfs/zipfs"
)
@@ -184,11 +182,10 @@
defer rc.Close() // be nice (e.g., -writeIndex mode)
fs.Bind("/", zipfs.New(rc, *zipfile), *goroot, vfs.BindReplace)
}
- if *templateDir != "" {
- fs.Bind("/lib/godoc", vfs.OS(*templateDir), "/", vfs.BindBefore)
- } else {
- fs.Bind("/lib/godoc", mapfs.New(static.Files), "/", vfs.BindReplace)
+ if *templateDir == "" {
+ *templateDir = "/usr/share/golang-golang-x-tools/godoc/static"
}
+ fs.Bind("/lib/godoc", vfs.OS(*templateDir), "/", vfs.BindReplace)
// Bind $GOPATH trees into Go root.
for _, p := range filepath.SplitList(build.Default.GOPATH) {
--- a/cmd/present/play.go
+++ b/cmd/present/play.go
@@ -11,8 +11,6 @@
"net/http"
"path/filepath"
"time"
-
- "golang.org/x/tools/godoc/static"
)
var scripts = []string{"jquery.js", "jquery-ui.js", "playground.js", "play.js"}
@@ -24,10 +22,6 @@
modTime := time.Now()
var buf bytes.Buffer
for _, p := range scripts {
- if s, ok := static.Files[p]; ok {
- buf.WriteString(s)
- continue
- }
b, err := ioutil.ReadFile(filepath.Join(root, "static", p))
if err != nil {
panic(err)
--- a/cmd/godoc/appinit.go
+++ b/cmd/godoc/appinit.go
@@ -20,7 +20,6 @@
"golang.org/x/tools/godoc/dl"
"golang.org/x/tools/godoc/proxy"
"golang.org/x/tools/godoc/short"
- "golang.org/x/tools/godoc/static"
"golang.org/x/tools/godoc/vfs"
"golang.org/x/tools/godoc/vfs/mapfs"
"golang.org/x/tools/godoc/vfs/zipfs"
@@ -47,7 +46,7 @@
}
// rc is never closed (app running forever)
fs.Bind("/", zipfs.New(rc, zipFilename), goroot, vfs.BindReplace)
- fs.Bind("/lib/godoc", mapfs.New(static.Files), "/", vfs.BindReplace)
+ fs.Bind("/lib/godoc", vfs.OS("/usr/share/golang-golang-x-tools/godoc/"), "/", vfs.BindReplace)
corpus := godoc.NewCorpus(fs)
corpus.Verbose = false
--- a/cmd/godoc/godoc_test.go
+++ b/cmd/godoc/godoc_test.go
@@ -101,8 +101,10 @@
func TestCLI(t *testing.T) {
bin, cleanup := buildGodoc(t)
defer cleanup()
+ args1 := []string{"-templates=../../godoc/static"}
for _, test := range godocTests {
- cmd := exec.Command(bin, test.args...)
+ args := append(args1, test.args...)
+ cmd := exec.Command(bin, args...)
cmd.Args[0] = "godoc"
out, err := cmd.CombinedOutput()
if err != nil {
@@ -194,7 +196,7 @@
bin, cleanup := buildGodoc(t)
defer cleanup()
addr := serverAddress(t)
- args := []string{fmt.Sprintf("-http=%s", addr)}
+ args := []string{fmt.Sprintf("-http=%s", addr), "-templates=../../godoc/static"}
if withIndex {
args = append(args, "-index", "-index_interval=-1s")
}
@@ -354,7 +356,7 @@
bin, cleanup := buildGodoc(t)
defer cleanup()
addr := serverAddress(t)
- cmd := exec.Command(bin, fmt.Sprintf("-http=%s", addr), "-analysis=type")
+ cmd := exec.Command(bin, fmt.Sprintf("-http=%s", addr), "-analysis=type", "-templates=../../godoc/static")
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() {
|