From 12c48ced94a7752f71687ef145a83a59e9a6f846 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 24 Aug 2015 14:26:10 -0700 Subject: [PATCH] cmd/gotype: use std lib go/types instead of x/tools version Change-Id: I89ba20512129d0557f3f606d8242472d78ea37a9 Reviewed-on: https://go-review.googlesource.com/13898 Reviewed-by: Brad Fitzpatrick --- cmd/gotype/doc.go | 4 ++-- cmd/gotype/gotype.go | 16 +++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/cmd/gotype/doc.go b/cmd/gotype/doc.go index ea0b2b1f..12e47413 100644 --- a/cmd/gotype/doc.go +++ b/cmd/gotype/doc.go @@ -27,8 +27,8 @@ The flags are: report all errors (not just the first 10) -v verbose mode - -gccgo - use gccimporter instead of gcimporter + -c + compiler used to compile packages (gc or gccgo); default: gc Debugging flags: -seq diff --git a/cmd/gotype/gotype.go b/cmd/gotype/gotype.go index 4a5c7de4..16a6440e 100644 --- a/cmd/gotype/gotype.go +++ b/cmd/gotype/gotype.go @@ -9,18 +9,16 @@ import ( "fmt" "go/ast" "go/build" + "go/importer" "go/parser" "go/scanner" "go/token" + "go/types" "io/ioutil" "os" "path/filepath" "runtime" "time" - - "golang.org/x/tools/go/gccgoimporter" - _ "golang.org/x/tools/go/gcimporter" - "golang.org/x/tools/go/types" ) var ( @@ -28,7 +26,7 @@ var ( allFiles = flag.Bool("a", false, "use all (incl. _test.go) files when processing a directory") allErrors = flag.Bool("e", false, "report all errors (not just the first 10)") verbose = flag.Bool("v", false, "verbose mode") - gccgo = flag.Bool("gccgo", false, "use gccgoimporter instead of gcimporter") + compiler = flag.String("c", "gc", "compiler used to compile packages (gc or gccgo)") // debugging support sequential = flag.Bool("seq", false, "parse sequentially, rather than in parallel") @@ -195,12 +193,8 @@ func checkPkgFiles(files []*ast.File) { } report(err) }, - Sizes: sizes, - } - if *gccgo { - var inst gccgoimporter.GccgoInstallation - inst.InitFromDriver("gccgo") - conf.Import = inst.GetImporter(nil, nil) + Importer: importer.For(*compiler, nil), + Sizes: sizes, } defer func() {