diff options
| author | Daniel Martà <mvdan@mvdan.cc> | 2019-04-15 23:10:50 +0900 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2019-04-16 14:43:48 +0000 |
| commit | 9b968df17782f21cc0af14c9d3c0bcf4cf3f911f (patch) | |
| tree | 0240ff2603a12a7f9206b27967b8a60b992110cb /src/cmd/api/goapi.go | |
| parent | b39d0eab902cb6b90aa99bcf11ca622c00219c7c (diff) | |
| download | go-git-9b968df17782f21cc0af14c9d3c0bcf4cf3f911f.tar.gz | |
all: clean up code with token.IsExported
A handful of packages were reimplementing IsExported, so use
token.IsExported instead. This caused the deps test to fail for net/rpc.
However, net/rpc deals with Go types, and go/token is light and fairly
low-level in terms of Go tooling packages, so that's okay.
While at it, replace all uses of ast.IsExported with token.IsExported.
This is more consistent, and also means that the import graphs are
leaner. A couple of files no longer need to import go/ast, for example.
We can't get rid of cmd/compile/internal/types.IsExported, as the
compiler can only depend on go/token as of Go 1.4. However, gc used
different implementations in a couple of places, so consolidate the use
of types.IsExported there.
Finally, we can't get rid of the copied IsExported implementation in
encoding/gob, as go/token depends on it as part of a test. That test
can't be an external test either, so there's no easy way to break the
import cycle.
Overall, this removes about forty lines of unnecessary code.
Change-Id: I86a475b7614261e6a7b0b153d5ca02b9f64a7b2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/172037
Run-TryBot: Daniel Martà <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/api/goapi.go')
| -rw-r--r-- | src/cmd/api/goapi.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/api/goapi.go b/src/cmd/api/goapi.go index 1a0242f60c..b728baea1d 100644 --- a/src/cmd/api/goapi.go +++ b/src/cmd/api/goapi.go @@ -241,7 +241,7 @@ func (w *Walker) export(pkg *types.Package) { w.current = pkg scope := pkg.Scope() for _, name := range scope.Names() { - if ast.IsExported(name) { + if token.IsExported(name) { w.emitObj(scope.Lookup(name)) } } |
