Skip to content

Commit bd44666

Browse files
committed
cmd/internal/doc: merge with cmd/go/internal/doc
Now that cmd/doc has been removed, cmd/go/internal/doc is the only user of the cmd/internal/doc code. Merge cmd/internal/doc into cmd/go/internal/doc. For #74667 Change-Id: I16bbe7b1f418b54ee411c8d6e6609c0973e40b3e Reviewed-on: https://go-review.googlesource.com/c/go/+/689836 Reviewed-by: Michael Pratt <[email protected]> Auto-Submit: Michael Matloob <[email protected]> Reviewed-by: Michael Matloob <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent da8b50c commit bd44666

File tree

13 files changed

+22
-19
lines changed

13 files changed

+22
-19
lines changed

src/cmd/internal/doc/dirs.go renamed to src/cmd/go/internal/doc/dirs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !cmd_go_bootstrap
6+
57
package doc
68

79
import (

src/cmd/go/internal/doc/doc.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
package doc
99

1010
import (
11-
"cmd/go/internal/base"
12-
"cmd/internal/doc"
1311
"context"
12+
"flag"
13+
"log"
14+
"os"
15+
16+
"cmd/go/internal/base"
1417
)
1518

1619
var CmdDoc = &base.Command{
@@ -136,5 +139,12 @@ Flags:
136139
}
137140

138141
func runDoc(ctx context.Context, cmd *base.Command, args []string) {
139-
doc.Main(args)
142+
log.SetFlags(0)
143+
log.SetPrefix("doc: ")
144+
dirsInit()
145+
var flagSet flag.FlagSet
146+
err := do(os.Stdout, &flagSet, args)
147+
if err != nil {
148+
log.Fatal(err)
149+
}
140150
}

src/cmd/internal/doc/doc_test.go renamed to src/cmd/go/internal/doc/doc_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestMain(m *testing.M) {
2929
buildCtx.GOROOT = testenv.GOROOT(nil)
3030
build.Default.GOROOT = testenv.GOROOT(nil)
3131

32-
// Add $GOROOT/src/cmd/doc/testdata explicitly so we can access its contents in the test.
32+
// Add $GOROOT/src/cmd/go/internal/doc/testdata explicitly so we can access its contents in the test.
3333
// Normally testdata directories are ignored, but sending it to dirs.scan directly is
3434
// a hack that works around the check.
3535
testdataDir, err := filepath.Abs("testdata")
@@ -90,7 +90,7 @@ type test struct {
9090
no []string // Regular expressions that should not match.
9191
}
9292

93-
const p = "cmd/internal/doc/testdata"
93+
const p = "cmd/go/internal/doc/testdata"
9494

9595
var tests = []test{
9696
// Sanity check.
@@ -105,7 +105,7 @@ var tests = []test{
105105
{
106106
"package clause",
107107
[]string{p},
108-
[]string{`package pkg.*cmd/internal/doc/testdata`},
108+
[]string{`package pkg.*cmd/go/internal/doc/testdata`},
109109
nil,
110110
},
111111

src/cmd/internal/doc/main.go renamed to src/cmd/go/internal/doc/main.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// Package doc provides the implementation of the "go doc" subcommand and cmd/doc.
5+
//go:build !cmd_go_bootstrap
6+
67
package doc
78

89
import (
@@ -53,18 +54,6 @@ func usage(flagSet *flag.FlagSet) {
5354
os.Exit(2)
5455
}
5556

56-
// Main is the entry point, invoked both by go doc and cmd/doc.
57-
func Main(args []string) {
58-
log.SetFlags(0)
59-
log.SetPrefix("doc: ")
60-
dirsInit()
61-
var flagSet flag.FlagSet
62-
err := do(os.Stdout, &flagSet, args)
63-
if err != nil {
64-
log.Fatal(err)
65-
}
66-
}
67-
6857
// do is the workhorse, broken out of main to make testing easier.
6958
func do(writer io.Writer, flagSet *flag.FlagSet, args []string) (err error) {
7059
flagSet.Usage = func() { usage(flagSet) }

src/cmd/internal/doc/pkg.go renamed to src/cmd/go/internal/doc/pkg.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !cmd_go_bootstrap
6+
57
package doc
68

79
import (

0 commit comments

Comments
 (0)