Skip to content

Commit 12c48ce

Browse files
committed
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 <[email protected]>
1 parent 6c9aff3 commit 12c48ce

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

cmd/gotype/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ The flags are:
2727
report all errors (not just the first 10)
2828
-v
2929
verbose mode
30-
-gccgo
31-
use gccimporter instead of gcimporter
30+
-c
31+
compiler used to compile packages (gc or gccgo); default: gc
3232
3333
Debugging flags:
3434
-seq

cmd/gotype/gotype.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,24 @@ import (
99
"fmt"
1010
"go/ast"
1111
"go/build"
12+
"go/importer"
1213
"go/parser"
1314
"go/scanner"
1415
"go/token"
16+
"go/types"
1517
"io/ioutil"
1618
"os"
1719
"path/filepath"
1820
"runtime"
1921
"time"
20-
21-
"golang.org/x/tools/go/gccgoimporter"
22-
_ "golang.org/x/tools/go/gcimporter"
23-
"golang.org/x/tools/go/types"
2422
)
2523

2624
var (
2725
// main operation modes
2826
allFiles = flag.Bool("a", false, "use all (incl. _test.go) files when processing a directory")
2927
allErrors = flag.Bool("e", false, "report all errors (not just the first 10)")
3028
verbose = flag.Bool("v", false, "verbose mode")
31-
gccgo = flag.Bool("gccgo", false, "use gccgoimporter instead of gcimporter")
29+
compiler = flag.String("c", "gc", "compiler used to compile packages (gc or gccgo)")
3230

3331
// debugging support
3432
sequential = flag.Bool("seq", false, "parse sequentially, rather than in parallel")
@@ -195,12 +193,8 @@ func checkPkgFiles(files []*ast.File) {
195193
}
196194
report(err)
197195
},
198-
Sizes: sizes,
199-
}
200-
if *gccgo {
201-
var inst gccgoimporter.GccgoInstallation
202-
inst.InitFromDriver("gccgo")
203-
conf.Import = inst.GetImporter(nil, nil)
196+
Importer: importer.For(*compiler, nil),
197+
Sizes: sizes,
204198
}
205199

206200
defer func() {

0 commit comments

Comments
 (0)