Index: src/cmd/gotype/gotype.go |
=================================================================== |
--- a/src/cmd/gotype/gotype.go |
+++ b/src/cmd/gotype/gotype.go |
@@ -18,7 +18,6 @@ |
"strings" |
) |
- |
var ( |
// main operation modes |
pkgName = flag.String("p", "", "process only those files in package pkgName") |
@@ -30,23 +29,19 @@ |
printAST = flag.Bool("ast", false, "print AST") |
) |
- |
var exitCode = 0 |
- |
func usage() { |
fmt.Fprintf(os.Stderr, "usage: gotype [flags] [path ...]\n") |
flag.PrintDefaults() |
os.Exit(2) |
} |
- |
func report(err os.Error) { |
scanner.PrintError(os.Stderr, err) |
exitCode = 2 |
} |
- |
// parse returns the AST for the Go source src. |
// The filename is for error reporting only. |
// The result is nil if there were errors or if |
@@ -88,7 +83,6 @@ |
return file |
} |
- |
func parseStdin(fset *token.FileSet) (files map[string]*ast.File) { |
files = make(map[string]*ast.File) |
src, err := ioutil.ReadAll(os.Stdin) |
@@ -103,7 +97,6 @@ |
return |
} |
- |
func parseFiles(fset *token.FileSet, filenames []string) (files map[string]*ast.File) { |
files = make(map[string]*ast.File) |
for _, filename := range filenames { |
@@ -123,13 +116,11 @@ |
return |
} |
- |
func isGoFilename(filename string) bool { |
// ignore non-Go files |
return !strings.HasPrefix(filename, ".") && strings.HasSuffix(filename, ".go") |
} |
- |
func processDirectory(dirname string) { |
f, err := os.Open(dirname) |
if err != nil { |
@@ -148,7 +139,6 @@ |
processFiles(filenames, false) |
} |
- |
func processFiles(filenames []string, allFiles bool) { |
i := 0 |
for _, filename := range filenames { |
@@ -170,7 +160,6 @@ |
processPackage(fset, parseFiles(fset, filenames[0:i])) |
} |
- |
func processPackage(fset *token.FileSet, files map[string]*ast.File) { |
// make a package (resolve all identifiers) |
pkg, err := ast.NewPackage(fset, files, types.GcImporter, types.Universe) |
@@ -184,7 +173,6 @@ |
} |
} |
- |
func main() { |
flag.Usage = usage |
flag.Parse() |