Commit 5f3a7aa2 authored by Andrew Gerrand's avatar Andrew Gerrand

go.tools/misc/dist: copy doc.go from go.tools to go root

This will allow "godoc godoc", "godoc vet", "godoc cover" to work.

Fixes #6527.

R=r, dsymonds
CC=golang-dev
https://golang.org/cl/14566049
parent 5516349f
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// This is a tool for packaging binary releases. // This is a tool for packaging binary releases.
// It supports FreeBSD, Linux, NetBSD, OS X, and Windows. // It supports FreeBSD, Linux, NetBSD, OpenBSD, OS X, and Windows.
package main package main
import ( import (
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
"net/http" "net/http"
"os" "os"
"os/exec" "os/exec"
"path"
"path/filepath" "path/filepath"
"regexp" "regexp"
"runtime" "runtime"
...@@ -480,7 +481,31 @@ func (b *Build) tools() error { ...@@ -480,7 +481,31 @@ func (b *Build) tools() error {
// Install tools. // Install tools.
args = append([]string{"install"}, toolPaths...) args = append([]string{"install"}, toolPaths...)
_, err = b.run(b.gopath, filepath.Join(b.root, "bin", "go"), args...) _, err = b.run(b.gopath, filepath.Join(b.root, "bin", "go"), args...)
if err != nil {
return err
}
// Copy doc.go from go.tools/cmd/$CMD to $GOROOT/src/cmd/$CMD
// while rewriting "package main" to "package documentation".
for _, p := range toolPaths {
d, err := ioutil.ReadFile(filepath.Join(b.gopath, "src",
filepath.FromSlash(p), "doc.go"))
if err != nil {
return err
}
d = bytes.Replace(d, []byte("\npackage main\n"),
[]byte("\npackage documentation\n"), 1)
cmdDir := filepath.Join(b.root, "src", "cmd", path.Base(p))
if err := os.MkdirAll(cmdDir, 0755); err != nil {
return err return err
}
docGo := filepath.Join(cmdDir, "doc.go")
if err := ioutil.WriteFile(docGo, d, 0644); err != nil {
return err
}
}
return nil
} }
func (b *Build) blog() error { func (b *Build) blog() error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment