Documentation ¶
Overview ¶
The gotype command, like the front-end of a Go compiler, parses and type-checks a single Go package. Errors are reported if the analysis fails; otherwise gotype is quiet (unless -v is set).
Without a list of paths, gotype reads from standard input, which must provide a single Go source file defining a complete package.
With a single directory argument, gotype checks the Go files in that directory, comprising a single package. Use -t to include the (in-package) _test.go files. Use -x to type check only external test files.
Otherwise, each path must be the filename of a Go file belonging to the same package.
Imports are processed by importing directly from the source of imported packages (default), or by importing from compiled and installed packages (by setting -c to the respective compiler).
Usage:
gotype [flags] [path...]
The flags are:
-t include local test files in a directory (ignored if -x is provided) -x consider only external test files in a directory -e report all errors (not just the first 10) -v verbose mode
Flags controlling additional output:
-ast print AST (forces -seq) -trace print parse trace (forces -seq) -comments parse comments (ignored unless -ast or -trace is provided)
Examples:
To check the files a.go, b.go, and c.go:
gotype a.go b.go c.go
To check an entire package including (in-package) tests in the directory dir and print the processed files:
gotype -t -v dir
To verify the output of a pipe:
echo "package foo" | gotype
Package srcimporter implements importing directly from source files rather than installed packages.
Directories ¶
Path | Synopsis |
---|---|
Package parser implements a parser for Go source files.
|
Package parser implements a parser for Go source files. |
Package types declares the data types and implements the algorithms for type-checking of Go packages.
|
Package types declares the data types and implements the algorithms for type-checking of Go packages. |