v2.0.11+incompatible Latest Latest

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

Go to latest
Published: Sep 9, 2018 License: MIT, BSD-3-Clause Imports: 14 Imported by: 0



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).

The -c flag must be set to a compiler ("gc", "gccgo") when type- checking packages containing imports with relative import paths (import "./mypkg") because the source importer cannot know which files to include for such packages.


gotype [flags] [path...]

The flags are:

	include local test files in a directory (ignored if -x is provided)
	consider only external test files in a directory
	report all errors (not just the first 10)
	verbose mode
	compiler used for installed packages (gc, gccgo, or source); default: source

Flags controlling additional output:

	print AST (forces -seq)
	print parse trace (forces -seq)
	parse comments (ignored unless -ast or -trace is provided)


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 check the external test package (if any) in the current directory, based on installed packages compiled with cmd/compile:

gotype -c=gc -x .

To verify the output of a pipe:

echo "package foo" | gotype

Jump to

Keyboard shortcuts

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