github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/go/types/gotype.go (about) 1 // Copyright 2011 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build ignore 6 7 // Build this command explicitly: go build gotype.go 8 9 /* 10 The gotype command, like the front-end of a Go compiler, parses and 11 type-checks a single Go package. Errors are reported if the analysis 12 fails; otherwise gotype is quiet (unless -v is set). 13 14 Without a list of paths, gotype reads from standard input, which 15 must provide a single Go source file defining a complete package. 16 17 With a single directory argument, gotype checks the Go files in 18 that directory, comprising a single package. Use -t to include the 19 (in-package) _test.go files. Use -x to type check only external 20 test files. 21 22 Otherwise, each path must be the filename of a Go file belonging 23 to the same package. 24 25 Imports are processed by importing directly from the source of 26 imported packages (default), or by importing from compiled and 27 installed packages (by setting -c to the respective compiler). 28 29 The -c flag must be set to a compiler ("gc", "gccgo") when type- 30 checking packages containing imports with relative import paths 31 (import "./mypkg") because the source importer cannot know which 32 files to include for such packages. 33 34 Usage: 35 36 gotype [flags] [path...] 37 38 The flags are: 39 40 -t 41 include local test files in a directory (ignored if -x is provided) 42 -x 43 consider only external test files in a directory 44 -e 45 report all errors (not just the first 10) 46 -v 47 verbose mode 48 -c 49 compiler used for installed packages (gc, gccgo, or source); default: source 50 51 Flags controlling additional output: 52 53 -ast 54 print AST 55 -trace 56 print parse trace 57 -comments 58 parse comments (ignored unless -ast or -trace is provided) 59 -panic 60 panic on first error 61 62 Examples: 63 64 To check the files a.go, b.go, and c.go: 65 66 gotype a.go b.go c.go 67 68 To check an entire package including (in-package) tests in the directory dir and print the processed files: 69 70 gotype -t -v dir 71 72 To check the external test package (if any) in the current directory, based on installed packages compiled with 73 cmd/compile: 74 75 gotype -c=gc -x . 76 77 To verify the output of a pipe: 78 79 echo "package foo" | gotype 80 */ 81 package main