1
0
mirror of https://github.com/golang/go synced 2024-10-01 01:38:33 -06:00
Commit Graph

2555 Commits

Author SHA1 Message Date
Alan Donovan
0bd7993ac0 go/ssa/interp: disable failing part of a test
The interpreter has no intrinsic for reflect.Value.MapRange,
so it no longer supports fmt.Sprint on a map, which uses it.
Suppressing part of complit.go test for now.

Change-Id: Id6ade19bdbb92593d6da57c82e75f311fb65b4fe
Reviewed-on: https://go-review.googlesource.com/131075
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-08-23 16:10:49 +00:00
Agniva De Sarker
ba93f9405e godoc: update to use new goroot finding logic
The logic to determine whether a filesystem root was in GOROOT or GOPATH
still relied on runtime.GOROOT(), whereas cmd/godoc was updated to copy
the goroot finding logic from standard library.

Hence, godoc is unable to determine if a filesystem is in GOROOT or not
when the binary is outside runtime.GOROOT(). So we expose a new variable
and set that from cmd/godoc to avoid copying the logic again for the 3rd time.

Fixes golang/go#27162

Change-Id: I160dcdbdd262e671f09f7bf01c329be5eac280ad
Reviewed-on: https://go-review.googlesource.com/130796
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-23 15:26:32 +00:00
Alan Donovan
447b503c8b go/packages: fix flaky TestJSON
Visit packages in deterministic order for predictable JSON.

(I don't know why the test only appears to fail on darwin;
I would expect it to randomly fail in linux 50% of the time.)

Change-Id: I5270804077fc9ca8f529a1f4657e1c35f0586579
Reviewed-on: https://go-review.googlesource.com/130755
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-08-22 15:05:42 +00:00
Brad Fitzpatrick
ef27ca3af5 cmd/godoc: redirect to https instead of http for blog.golang.org
And update some comments.

Change-Id: I4e0b7062fa0d12982ad0f9ee150635cf11ed247c
Reviewed-on: https://go-review.googlesource.com/130555
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-08-22 02:22:54 +00:00
Jay Conrod
5fad05c818 go/packages: rename config.Flags to BuildFlags
This change adds the -buildflag argument to go/packages/gopackages,
which may be passed repeatedly to set config.BuildFlags. I felt -flag
was too vague.

config.Flags is renamed to config.BuildFlags for consistency, and
packages.findExternalDriver now passes -buildflag instead of -flag to
drivers. This will break existing drivers.

Change-Id: Iaed58026373a46e137a236ee9a652eb3a9433ee3
Reviewed-on: https://go-review.googlesource.com/130136
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-21 16:42:13 +00:00
Alan Donovan
c1406c36ef go/packages: fix test failing on go1.10
The legacy implementation currently always loads from source code, so
packages are more complete than expected.

Change-Id: Ib8c9f7ac590038108dba05c1f47d22e70734945c
Reviewed-on: https://go-review.googlesource.com/130095
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-08-20 21:11:00 +00:00
Dominik Honnef
44ec670fe7 cmd/digraph: print usage on -h
Also switch usage printing to using stderr always, as is common for Go
tools.

Change-Id: I240da4344fe6b51a418c0d4b0b7d7e7d5614c1d7
Reviewed-on: https://go-review.googlesource.com/129776
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-20 20:10:23 +00:00
Alan Donovan
7395529d16 go/packages: disable failing test on plan9
Updates golang/go#27100

Change-Id: I41528e3635a9d7a68c84c3f089a3b4634469830d
Reviewed-on: https://go-review.googlesource.com/129975
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-20 18:05:05 +00:00
Alan Donovan
7d1dc99761 go/packages: smooth API documentation for release
Change-Id: Ia3d06a320228831115eb0e0e99d45a84a812da03
Reviewed-on: https://go-review.googlesource.com/129636
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-08-17 17:07:05 +00:00
Ian Cottrell
641913b2bd go/packages: reduce the number of export data files loaded
In ModeTypes, we only need the roots, in ModeSyntax we need the direct
dependancies.
We now do exactly what we need rather than the entire set of transitive
dependancies.
Without this change tools operating on source of a deep dependancy tree are far
to slow.

Change-Id: I3ddbe660709184758ad33ab7cdea860244433ce6
Reviewed-on: https://go-review.googlesource.com/129355
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-17 16:41:42 +00:00
Ian Cottrell
1dfe8478fd go/packages: disable modules in all tests that set GOPATH
Change-Id: I940e3eebe2f2f5c3ab75b6961fc90ba7e26cdf56
Reviewed-on: https://go-review.googlesource.com/129496
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-16 15:27:21 +00:00
Alan Donovan
9de1900191 go/packages: opt: ignore function bodies in non-initial packages
This saves 35% of wall time in a command such as

 $ gopackages -mode=syntax golang.org/x/tools/go/packages/gopackages fmt

that would otherwise typecheck every function in each package that
depends on fmt. It also applies in -mode=types when source was loaded
as a fall back for missing export data due to an error in a lower package.

Also, remove Config.TypeChecker field now that not a single of its
subfields is passed through go/packages to the type checker.
(The Sizes function is logically a result, not an input, of loading,
though we have yet to implement it properly.)

Change-Id: I472d21b34fc5e2832f7353e82992a67a06e4e4cc
Reviewed-on: https://go-review.googlesource.com/129497
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-08-16 00:26:32 +00:00
Andrew Bonventre
8f8fd1f239 playground: increase urlfetch timeout on GAE classic
The default timeout for urlfetch requests on App Engine Classic is
5 seconds. Sometimes the requests can take longer, so increase it to
the maximum value of 60 seconds. The playground has its own timeout for
running code so there's no need to impose a second level of protection.

Also cleans up the code to remove old appenginevm code and use the
correct imports.

Change-Id: I15da96e5ba70fb008bf821f4609f431847662223
Reviewed-on: https://go-review.googlesource.com/129395
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-14 23:19:41 +00:00
Dominik Honnef
a434f64ace go/pointer: support reflect.Value in AddExtendedQuery
We were calling types.Type.Underlying() too early, which caused CanPoint
to see an ordinary struct, not reflect.Value.

Change-Id: I23ba3b9451bc1abc1ad8a45c790d2e22c1481f26
Reviewed-on: https://go-review.googlesource.com/129196
Run-TryBot: Dominik Honnef <dominik@honnef.co>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-13 20:51:10 +00:00
Alan Donovan
87c7dcbd5d cmd/callgraph: temporarily disable failing tests on go1.10
go1.10 and earlier versions of go list do not report test main packages.
Furthermore, go/packages has errors in its Imports under go1.10.

The long-term fix is for go/packages to synthesize test main packages
when working with older versions of the go command, but in the
meantime we will disable the tests.

Updates golang/go#11811

Change-Id: Ifd5e37d5b68a01134e911fda90e30a39fc25b88d
Reviewed-on: https://go-review.googlesource.com/129175
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-13 17:53:22 +00:00
Rebecca Stambler
e10408200f cmd/guru: fix tests for line directives in Go 1.11
Go 1.11 changed the behavior of line directives, so reflect that in the
golden files for tests.

Change-Id: I7df282dfbeb3bfc5d75481c345acf724bb0b25bf
Reviewed-on: https://go-review.googlesource.com/128999
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-13 16:50:33 +00:00
Alan Donovan
27709f6afe cmd/ssadump: use go/packages
Unlike go/loader's FromArgs, go/packages doesn't return the
non-package arguments, so we add a new repeated flag -arg=x -arg=y to
specify them.

Because we cannot add packages to a packages.Load query, we emit an
error if -run is specified and "runtime" is not among the
dependencies.

There is no easy way to distinguish synthetic test main packages
from regular main packages, so we no longer try.
This makes -test and -run orthogonal.

Change-Id: Ibd69b993c05de62df01dde52218a9e266cd63a71
Reviewed-on: https://go-review.googlesource.com/128837
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-08-10 20:16:25 +00:00
Rebecca Stambler
cf99646d84 imports: stub out dirPackageInfo function in tests
TestFixImports did not have to explicitly add "strings" to the
simplePkgs map - this only happened because sibling files were searched
and the strings import was found through them. If we stub out the
dirPackageInfo function, we have to explicitly add the strings import.

Change-Id: I149e522fad37039fc790e6a855834d86ff050674
Reviewed-on: https://go-review.googlesource.com/129036
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-10 19:55:50 +00:00
Ian Cottrell
7883bde2a5 go/packages: minor fixes
This is fixes for review comments made on cl/128120

Change-Id: Ie6382d6ec91db2bbdece564a83ae028be4e2e269
Reviewed-on: https://go-review.googlesource.com/129000
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-10 19:50:59 +00:00
Suzy Mueller
69b93a3d4a go/packages: prefer import map to identity imports
For any identity imports to be added to the import map of a package,
make sure these are not already in there.  If the package imports "C",
be sure not to overwrite the import map entries for "runtime/cgo", "unsafe",
and "syscall".

Test the import map when test variants are loaded. This tests the fix
in 'go list' made by https://golang.org/cl/128836

Fixes golang/go#26847

Change-Id: I05dff4d3a75fab03f333f6d88128de6a6bf169e6
Reviewed-on: https://go-review.googlesource.com/128876
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-10 19:35:07 +00:00
Kazuhiro Sera
4354ead92e all: fix typos in comments
This pull request fixes several typos in comments. I believe that they're safe enough.

Change-Id: Ic7c594bdb89dcd04f8775f225abbc0f966f3728e
GitHub-Last-Rev: 2394feb263714c83b419f45eccb3c6c9fdff7fed
GitHub-Pull-Request: golang/tools#45
Reviewed-on: https://go-review.googlesource.com/128956
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-10 18:15:57 +00:00
Alan Donovan
e96c4e2476 x/tools: remove old renaming imports of go/constant as exact
Fixes golang/go#26522

Change-Id: Ie8184a358f11bc7ad855e0eeb964c29848d2263e
Reviewed-on: https://go-review.googlesource.com/128998
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-10 17:04:37 +00:00
Rebecca Stambler
00d4fcd841 go/packages: remove dependency on imports
Copy imports.VendorlessPath into go/packages to avoid an unnecessary
dependency on imports.

Change-Id: Ie77c2fb87f2199f139ece9f3d1b707f065fc1a79
Reviewed-on: https://go-review.googlesource.com/128996
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-10 17:01:50 +00:00
Ian Cottrell
af5e78811a go/packages: use Package as the raw form
This deletes the raw and golist packatges, instead using the main
Package structure as the serialzied form between the build tool and the
loader.
This requires a few new fields on Package for information that we used
to hide, and some extra json tags on Package.
It also required Package to have custom JSON marshalling methods.

Change-Id: Ib72171bc93e2b494b97f4b0266504acaa9b3f647
Reviewed-on: https://go-review.googlesource.com/128120
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-10 14:45:52 +00:00
Russ Cox
4432cd1c27 cmd/compilebench: fix GOROOT inconsistencies
If GOROOT is unset (as is common now),
then the output of "go env GOROOT" may
differ from the GOROOT inferred by alternate
compilers being executed and also from the
value of runtime.GOROOT() inside compilebench,
used by go/build. Harmonize all of these by
setting GOROOT explicitly (will fix subcommands)
and by invoking the go command to learn about
packages instead of assuming go/build has any
idea what it's doing.

Change-Id: If97aa76cc2afec11a8404975f39329db7eb452e0
Reviewed-on: https://go-review.googlesource.com/109516
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-08-10 00:27:41 +00:00
Michael Matloob
aaa76ee82d go/packages: cleanup style
This change addresses some style issues pointed out by rsc in
golang.org/cl/126177. It doesn't fix the comment on listfunc
or the comment on the processing of the containing directories.
Those will be handled in a separate cl.

Change-Id: I2094ad1e5e2ee181a646466675f4d993bd69ff9b
Reviewed-on: https://go-review.googlesource.com/128897
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-09 21:03:15 +00:00
Michael Matloob
0167fde410 go/packages: make corrections to fallback golist processing
This change addresses adonovan's comments in golang.org/cl/125939.
Make sure to include CXXFiles, MFiles, HFiles, FFiles, SwigFiles,
SwigCXXFiles, and SysoFiles from the go list output into the Package
struct's OtherFiles field.
When computing packages from the output of fallback golist,
make sure to create the test variant of a package whenever creating
an x_test for a package because the x_test always depends on
the test variant even when there are no non-x_test files.
Sort dependency packages from the fallback golist to ensure
output is deterministic.

Change-Id: I3a942898c7edbe0ad62dbdf3d521775ffd9b9594
Reviewed-on: https://go-review.googlesource.com/128838
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-09 18:57:07 +00:00
Alan Donovan
2e5c1e6f75 go/packages: make LoadFiles the zero mode
Also:
- make a nil *Config equivalent to new(Config).
- add a test for nil *Config.
- document that Load may return an empty list of packages.

Change-Id: I642133abe18553ca8c7f46b7bd2709a03eda0b28
Reviewed-on: https://go-review.googlesource.com/128875
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-08-09 18:40:53 +00:00
Suzy Mueller
2fda359797 go/packages: use export data to load types info
Use export data in LoadTypes mode, when it is available to get the type information.

The lock can be moved back to loadFromExportData, as each package is
loaded in topological order, and all calls to loadFromExportData for a
particular package occur when that package is being loaded.

Fixes golang/go#26834

Change-Id: Ib6c28eb8642a473cc100d54d0aac7b90644d5d22
Reviewed-on: https://go-review.googlesource.com/128365
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-09 18:26:40 +00:00
Alan Donovan
1bd72987c2 cmd/callgraph: use go/packages
Because go/packages presents each synthesized test main package
as a first-class package, the tests now analyze all of the dependencies
of "testing", which they previously avoided.  This makes the tests
slower and the resulting call graph much larger,
so they now look for a subset match, not an exact match,
on the set of graph edges.

Change-Id: I9d7acf420e41cbffc03ca8423f5afb3ef671d775
Reviewed-on: https://go-review.googlesource.com/128695
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-08-09 16:04:36 +00:00
Dominik Honnef
2fad9c5652 go/ssa: emit position information for assignment operators
Fixes golang/go#26294

Change-Id: Ica2aa9787c58f703aa65786c2123a28b820af45d
Reviewed-on: https://go-review.googlesource.com/128776
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-09 14:07:54 +00:00
Russ Cox
ad8705d9f6 godoc/redirect: redirect design docs to Gerrit, not GitHub
Gerrit's rendering is cleaner and Gerrit is the source of truth anyway.

Fixes golang/go#26871.

Change-Id: I0bf69d174662c7acc083b03b009bac92f781a17c
Reviewed-on: https://go-review.googlesource.com/128596
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-08-08 21:07:32 +00:00
Alan Donovan
5b5e9c877a go/ssa: updates to support go/packages
Adds ssautil.Packages function, which creates ssa.Packages
from packages.Packages.

Deprecates testmain synthesis logic now that go/packages
reports the test packages synthesized by the build system
as first-class packages.

Updates docs, examples, and tests.

Flags potential confusion around legacy concept of "importable" packages.

Change-Id: I6d9cd7c6436c715d1ef39e3e280f4af4d48ccc5a
Reviewed-on: https://go-review.googlesource.com/128675
Reviewed-by: Dominik Honnef <dominik@honnef.co>
2018-08-08 20:03:34 +00:00
Michael Matloob
62181fabb0 go/internal/cgo: simplify names of ProcessCgoFiles and RunCgo
Also collect errors so we can set them on the Package (once
golang.org/cl/128120 is in).

Change-Id: I2950405404f060312813e4aa27393496078a3b7e
Reviewed-on: https://go-review.googlesource.com/128357
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-08 19:23:19 +00:00
Alan Donovan
201986631b go/packages: initialise Fset if mode >= Types
...as it is required not just for Syntax processing but also
when loading export data.

Clarify comments surrounding Types, Fset.
Remove bogus comment re: Dir.

Change-Id: I8d234bc311d73cbed4fd271ef883ebba22ba2708
Reviewed-on: https://go-review.googlesource.com/128595
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-08-08 18:17:01 +00:00
Suzy Mueller
e832138124 go/packages: make cache names predictable in tests
Check for the go-build subdirectory to identify a filepath in the go
build cache.  The go command uses a subdirectory of the default os cache
called "go-build" for the build cache.

Additionally, this responds to the comments about function names and tests in the following
CLs:
https://golang.org/cl/125536
https://golang.org/cl/125302

Fixes https://github.com/golang/go/issues/26387

Change-Id: I4ec65822e1e178d3de215a773e42f09fcc5bdb0d
Reviewed-on: https://go-review.googlesource.com/128360
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-08-08 16:32:21 +00:00
Michael Matloob
ca6481ae56 go/packages/golist: fix golist fallback selection
The fallback was being reset to the incorrect value
after it was set. This change fixes it.

Also add a test that triggers the fallback (a query with both
a contains: line and a regular package path).

Change-Id: I49a9aeb3a0c7d7cc308ac56f4985545315a5bfd2
Reviewed-on: https://go-review.googlesource.com/128356
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-07 20:59:40 +00:00
Ian Cottrell
3c07937fe1 go/packages: enable an external source of package information
This allows an external binary (not go list) to be the source of package
information.
It uses a binary called gopackagesraw if present in the PATH.
The binary can be overriden by specifying the GOPACKAGESRAW
environment variable.
The command must accept the -test -deps -export and -flags, and take a
list of package patterns to match. It then returns a raw.Results followed by
the matching raw.Package structs in json format on stdout.

Change-Id: I836014d837a284999ded0c1157b8e6dac058ba69
Reviewed-on: https://go-review.googlesource.com/125938
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-08-03 18:01:56 +00:00
Michael Matloob
1f25352b1e go/packages: add cgo support to go1.10 fallback loader
This change moves the cgo support for go loader to a common
internal package that can be reused by go/packages. That
support is used to invoke cgo to process the files returned
by the fallback pre-go1.11 Go list.

The cgo processing does not propagate all of the config correctly.
We're building a go/build.Package to get the cgo command line
invocation and it might be incorrectly configured if the user's
configuration is different from go/build.Default.

Change-Id: I0de3c65cb723587e1551edeb77219614ba9650bf
Reviewed-on: https://go-review.googlesource.com/127816
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-08-03 18:01:09 +00:00
Michael Matloob
82515cf895 go/packages: fix race detected by race detector
Diamonds in the dependency graph could cause the same package
to be processed by two separate gorotines, causing a potential
race between checking if the package's Types field is set, and
setting the field.

adonovan's comment suggested this might be unnecessary. We'll
ask him about this once he returns from his vacation.

Change-Id: I27511b6e44bb1b6a04ea294206fd8ed4ea60f56f
Reviewed-on: https://go-review.googlesource.com/127636
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-02 19:53:59 +00:00
Michael Matloob
4a42e0a488 go/packages/golist: pass in -compiled to go list
This is mostly straightforward, except that go list -e -compiled
will now return errors if a package can't build. This is a bug.
We need to skip the errors test until that's fixed.

For now, don't try to run go list with no arguments because it will
fail. So when all arguments are contains, we will check for empty
patterns and skip running go list.

Change-Id: I7c92b1bf9448e5dbea22f9ade9fb9429945e3719
Reviewed-on: https://go-review.googlesource.com/127339
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-08-02 18:51:39 +00:00
Suzy Mueller
78b3e71765 go/packages: include test deps in golist fallback
In Go 1.10 and earlier, the Deps field returned by go list does not
include the dependencies of any test files.  To get the dependencies
of the test packages, we need to run go list another time (for a total
of 3 calls to go list), to get the dependencies of the packages the
tests import.

Fixes golang/go#26753

Change-Id: Id3b424ac935e5ed459b4d4a55630715171bb9710
Reviewed-on: https://go-review.googlesource.com/127457
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-02 17:10:33 +00:00
Ian Cottrell
681bc0c94c go/packages: fix the documentation
It got out of sync after the round of API design changes, this brings it
back in line.
Also fix the behavior of passing nil as the config to match the
expected/documented behavior.

Change-Id: I8b51f5bd29ef9338ddb920fb872d857f180f9c84
Reviewed-on: https://go-review.googlesource.com/127255
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-08-02 15:09:54 +00:00
Michael Matloob
1801cb7c15 go/packages/golist: remove -cgo flag from go list invocation
It's been removed from go list.

Change-Id: I45b496bb6b693462484b1089cdb89c4e19e35b2e
Reviewed-on: https://go-review.googlesource.com/127341
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-08-01 20:59:36 +00:00
Ian Cottrell
8149a73649 go/packages: extract the raw API to its own package
We want to make it public to enable external sources of information
(other than go list), but we don't want to clutter the main
go/packages API with things that are intended for implementers only.
We also want to move the two API's from experimental to stable at
different times.
We also need to split the API because the golist implementation has to depend on
the raw structs, and then the main packages.Load has to depend on the golist
implementation.

The golist functionality is now in it's own package, and provides a Load method
to return the raw structures. This can be re-used by more complex raw providers.

Change-Id: I767af216b0d1ad9391e613cbf24eb2db5f503369
Reviewed-on: https://go-review.googlesource.com/126718
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-08-01 17:44:00 +00:00
Ian Cottrell
7ebc57ba19 go/packages: remove DepOnly from the raw package
All the other members of raw package are stable for any given package,
DepOnly relates to the query patterns, not thepackages.
Instead the raw functions now return the set of roots matched

Other minor changes included:
rawConfig.ExtraFlags -> rawConfig.Flags
delete rawConfig.Context

Change-Id: I3a729fa4557043f65da386eed94ab46fdfacb8ad
Reviewed-on: https://go-review.googlesource.com/127035
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-08-01 17:19:07 +00:00
Ian Cottrell
33176b2029 go/packages: make a test Errorf into Fatalf
It is a bounds check on an array before an access, the test cannot
continue safely if it fails, so it should be fatal.

Change-Id: Icd081df9cb81d549519d69bd34739d950946ccf5
Reviewed-on: https://go-review.googlesource.com/126975
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-31 19:12:26 +00:00
Mostyn Bramley-Moore
9e9f7f69ec godoc: skip build tag annotations when displaying examples
After moving the filepath.Walk example to a standalone example file
in CL 122237 (so it could use a standalone function), godoc includes
the build tag annotation ("// +build !windows,!plan9" in this case)
in the runnable example.  The example runs correctly, but the
annotation might be confusing for new users.

Change the behavior so that godoc skips these annotations when
displaying examples.

To avoid false positives in older versions of "go vet", which are still used
on the build dashboard, we avoid using a multiline string in the test.

Fixes golang/go#26490.

Change-Id: I1da4b3b7e1e5a85a76773e25d9355b3f92479c19
GitHub-Last-Rev: bc5ed29bd368e5bcf11fed7a0c7f14b872fef065
GitHub-Pull-Request: golang/tools#42
Reviewed-on: https://go-review.googlesource.com/126256
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-31 18:38:43 +00:00
Ian Cottrell
ade7853a2a go/packages: allow Load to use source if no export data is possible
We ask the underlying tool to produce export data if needed, but if it
cant we should fall back to source rather than just failing.

Change-Id: I376d41b4c8ad4d3c1aef3ca4ab4e3d0466b83b56
Reviewed-on: https://go-review.googlesource.com/126875
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-31 16:59:11 +00:00
Ian Cottrell
cfaff8d5db go/packages: fix tests for new go list behaviour
go list has been changed so that when -tests is added it reports the
test packages as well as the test mains in the initial set.
This fixes all the tests that assumed the old behaviour.
I changed the test that checked the initial set to check the entire
graph because the comparison became unreadable with the expanded set,
and this seemd like a nicer standardised way to check the behaviour.

Change-Id: I69404f8ef77cd092b0f02011a7789db71bee9b47
Reviewed-on: https://go-review.googlesource.com/126796
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-31 16:04:58 +00:00