doc

package
v1.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2023 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Overview

Doc (usually run as go doc) accepts zero, one or two arguments.

Zero arguments:

go doc

Show the documentation for the package in the current directory.

One argument:

go doc <pkg>
go doc <sym>[.<methodOrField>]
go doc [<pkg>.]<sym>[.<methodOrField>]
go doc [<pkg>.][<sym>.]<methodOrField>

The first item in this list that succeeds is the one whose documentation is printed. If there is a symbol but no package, the package in the current directory is chosen. However, if the argument begins with a capital letter it is always assumed to be a symbol in the current directory.

Two arguments:

go doc <pkg> <sym>[.<methodOrField>]

Show the documentation for the package, symbol, and method or field. The first argument must be a full package path. This is similar to the command-line usage for the godoc command.

For commands, unless the -cmd flag is present "go doc command" shows only the package-level docs for the package.

The -src flag causes doc to print the full source code for the symbol, such as the body of a struct, function or method.

The -all flag causes doc to print all documentation for the package and all its visible symbols. The argument must identify a package.

For complete documentation, run "go help doc".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dir

type Dir struct {
	// contains filtered or unexported fields
}

A Dir describes a directory holding code by specifying the expected import path and the file system directory.

type Dirs

type Dirs struct {
	// contains filtered or unexported fields
}

Dirs is a structure for scanning the directory tree. Its Next method returns the next Go source directory it finds. Although it can be used to scan the tree multiple times, it only walks the tree once, caching the data it finds.

func (*Dirs) Next

func (d *Dirs) Next() (Dir, bool)

Next returns the next directory in the scan. The boolean is false when the scan is done.

func (*Dirs) Reset

func (d *Dirs) Reset()

Reset puts the scan back at the beginning.

type Package

type Package struct {
	// contains filtered or unexported fields
}

func (*Package) Fatalf

func (pkg *Package) Fatalf(format string, args ...any)

pkg.Fatalf is like log.Fatalf, but panics so it can be recovered in the main do function, so it doesn't cause an exit. Allows testing to work without running a subprocess. The log prefix will be added when logged in main; it is not added here.

func (*Package) Printf

func (pkg *Package) Printf(format string, args ...any)

func (*Package) ToText

func (p *Package) ToText(w io.Writer, text, prefix, codePrefix string)

type PackageError

type PackageError string // type returned by pkg.Fatalf.

func (PackageError) Error

func (p PackageError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL