// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !cmd_go_bootstrap
+
package doc
import (
package doc
import (
- "cmd/go/internal/base"
- "cmd/internal/doc"
"context"
+ "flag"
+ "log"
+ "os"
+
+ "cmd/go/internal/base"
)
var CmdDoc = &base.Command{
}
func runDoc(ctx context.Context, cmd *base.Command, args []string) {
- doc.Main(args)
+ log.SetFlags(0)
+ log.SetPrefix("doc: ")
+ dirsInit()
+ var flagSet flag.FlagSet
+ err := do(os.Stdout, &flagSet, args)
+ if err != nil {
+ log.Fatal(err)
+ }
}
buildCtx.GOROOT = testenv.GOROOT(nil)
build.Default.GOROOT = testenv.GOROOT(nil)
- // Add $GOROOT/src/cmd/doc/testdata explicitly so we can access its contents in the test.
+ // Add $GOROOT/src/cmd/go/internal/doc/testdata explicitly so we can access its contents in the test.
// Normally testdata directories are ignored, but sending it to dirs.scan directly is
// a hack that works around the check.
testdataDir, err := filepath.Abs("testdata")
no []string // Regular expressions that should not match.
}
-const p = "cmd/internal/doc/testdata"
+const p = "cmd/go/internal/doc/testdata"
var tests = []test{
// Sanity check.
{
"package clause",
[]string{p},
- []string{`package pkg.*cmd/internal/doc/testdata`},
+ []string{`package pkg.*cmd/go/internal/doc/testdata`},
nil,
},
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package doc provides the implementation of the "go doc" subcommand and cmd/doc.
+//go:build !cmd_go_bootstrap
+
package doc
import (
os.Exit(2)
}
-// Main is the entry point, invoked both by go doc and cmd/doc.
-func Main(args []string) {
- log.SetFlags(0)
- log.SetPrefix("doc: ")
- dirsInit()
- var flagSet flag.FlagSet
- err := do(os.Stdout, &flagSet, args)
- if err != nil {
- log.Fatal(err)
- }
-}
-
// do is the workhorse, broken out of main to make testing easier.
func do(writer io.Writer, flagSet *flag.FlagSet, args []string) (err error) {
flagSet.Usage = func() { usage(flagSet) }
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !cmd_go_bootstrap
+
package doc
import (