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

2475 Commits

Author SHA1 Message Date
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
Andrew Bonventre
0700b576e4 godoc: don't display tar instructions for malformed download query
Ensure that the filename passed via ?download= matches the given
regexp before showing the command-line instructions to download it.

Change-Id: Ieb7c6912409474f31637ff1193fd195eb9f172b3
Reviewed-on: https://go-review.googlesource.com/126717
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-07-30 21:13:59 +00:00
Suzy Mueller
8cc4e8a6f4 go/packages: add Flags to Config
Add the Flags field to the Config struct in packages to provide a way
for users to pass along additional information to the underlying query
tool.

Since users that need Flags will already know something about the build
system they are using (and flags will vary depending on the underlying
build system), they can pass through the flags that they need for that
build system.

For example, build tags should be passed through using the Flags field in go build,
using "-tags=".

Change-Id: Ia65bf0d003db2f6d9aaad6cd09c602f4bc5bf3e3
Reviewed-on: https://go-review.googlesource.com/125302
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-07-27 19:51:41 +00:00
Michael Matloob
9dbe528bbb go/packages: add support for 'contains:' words
If a 'word' provided to go/packages' Load function starts with contains,
go/packages will interpret that word as the package containing the given
file.

For example:
   packages.Load(config, "contains:/usr/local/go/src/fmt/format.go")
would load the fmt package from the Go installation at /usr/local/go.

This implementation uses "go list ." in the directory the file is
contained in to find the package, but this won't work in the module
cache. We plan to add support to go list directly to help find the
containing package. Then, because we won't need to change directory,
go list will have knowledge of the correct vgo root module, and will
be able to surface correct results.

Change-Id: I6bff62447c12f13dae5e4c0c65f729d9f271c388
Reviewed-on: https://go-review.googlesource.com/126177
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-07-27 19:42:20 +00:00
Andrew Bonventre
bfb5194568 Revert "godoc: skip build tag annotations when displaying examples"
This reverts commit faa8a71ab5.

Reason for revert: +build tag in test causes build to fail :(

Change-Id: I8942a6dcc29faaceada23b63ba80ea881b3b2ca6
Reviewed-on: https://go-review.googlesource.com/126195
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-26 21:04:03 +00:00
Mostyn Bramley-Moore
faa8a71ab5 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.

With this change, godoc skips these annotations when displaying examples.

Fixes golang/go#26490.

Change-Id: Ice3d6a2ce4db5b5176c9c6fcabc01b69c323016d
GitHub-Last-Rev: 52beabd3d2a9cb9a556bfa3bd998a2e31ac96960
GitHub-Pull-Request: golang/tools#40
Reviewed-on: https://go-review.googlesource.com/125040
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-26 20:38:08 +00:00
Suzy Mueller
0bf5a32247 go/packages: add tests for vendoring
Test that the import graph for packages in the GOPATH that use vendoring
are correct and are keyed by the import path as it appears in the source
file.

Change-Id: Ibf9a516b4bfcc9f2d45f349d2ae49a0dbf958e30
Reviewed-on: https://go-review.googlesource.com/125298
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-07-26 17:31:39 +00:00
Suzy Mueller
54429628ee go/packages: test absolute filepaths
Paths to files in a Package should exist and be absolute.

Check that both GoFiles and OtherFiles are absolute paths.

Change-Id: I381830425ef313a91fa49be4d1751631d0a3a0c8
Reviewed-on: https://go-review.googlesource.com/125536
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-26 17:13:15 +00:00
Suzy Mueller
83365fc83f go/packages: fix bug preventing build
Change-Id: Ia5bc184c3762dc00338bfad182371568827da75e
Reviewed-on: https://go-review.googlesource.com/126095
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-26 17:03:46 +00:00
Michael Matloob
ceb18cec46 go/packages: switch fallback implementation to use go list
The go/loader based implementation was too different. Instead
Just call go list twice to get all the dependencies. This immediately
enables more functionality.

Change-Id: I22883492e996133bc61664314318c5e0a9cc10dc
Reviewed-on: https://go-review.googlesource.com/125939
Reviewed-by: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-07-26 16:53:35 +00:00
Ian Cottrell
475b7a1e12 go/packages: fix the gopackages command
It got broken when we renamed all the modes, and because it is just an
example binary it is not testsed.

Change-Id: Ia6608af574d0abebb4fe0d967e1bed88af6563bd
Reviewed-on: https://go-review.googlesource.com/125937
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-25 23:55:34 +00:00
Ian Cottrell
b1e4acd68a go/packages: alter the internal api to go list
This separates the go list specific behavior from the generalised go/packages
loading behaviour, to enable alternate build system back ends.

Change-Id: I07e7649f8f2afc7470a3ee3d0d743cbbcc6f713e
Reviewed-on: https://go-review.googlesource.com/125715
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-25 20:44:53 +00:00
Brad Fitzpatrick
65cc56d756 godoc: fix tests on Go 1.9
Updates golang/go#11811
Updates golang/go#26531

Change-Id: I9cc7daf551b76c3f06b9dd827c5733513c06895e
Reviewed-on: https://go-review.googlesource.com/125816
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-25 19:11:30 +00:00
Ian Cottrell
14e571052b go/packages: fix internal go list function signatures
After a discussion in cl/125535 this is a proposal to clean up some
internal function signatures that were becomming unwieldy.

Change-Id: I37a9e525ab18dface9ea9fb0b0ec68ac942ee632
Reviewed-on: https://go-review.googlesource.com/125659
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-25 19:03:22 +00:00
Agniva De Sarker
4d8a0ac9f6 cmd/godoc: fix TestWeb for versions < 1.11
The test was looking for strings found in specific Go versions
without checking for the actual Go version running the test.

Used ReleaseTags to check whether the current go version should
execute a test or not.

P.S. The version info is inferred from the binary running the test.
But the test builds godoc using the "go" binary in $PATH. In case
one is testing different go versions, please ensure to run tests
by changing the $PATH variable to point to different go versions,
rather than using a custom go binary in a different path.

Fixes golang/go#26531

Change-Id: I16dda81518021e865e79c9c29fc2d9e8a83e7057
Reviewed-on: https://go-review.googlesource.com/125755
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-25 15:26:38 +00:00
Michael Matloob
526516e9c4 go/packages: support pre go1.10.4 using go/loader
If go list fails because it doesn't support the new flags added
for Go 1.11 (which will be also released in Go 1.10.4) try again
using the Loader to approximate the packages requested.

This implementation is incomplete. It will never support test packages
because of the two phase test loading process of the Loader. It
also doesn't reliably have access to export data so it will
always do an upgraded whole-program query. But we'll try to get
the best level of support we can for the go/packages interface
given the limitations of the loader.

Once Go 1.12 is released, we'll delete this support. By then, most
Go users should have at least switched to Go 1.10.4.

Change-Id: I5248e20980032695a86b052caa9ff368ecf7b142
Reviewed-on: https://go-review.googlesource.com/125616
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-07-25 00:20:46 +00:00
Ian Cottrell
214274eeeb go/packages: changes to the API per CL 125305
Collapse the main entry points to the single Load function.
Make public the Mode enumeration in the Config.
Add a lowest level mode that does not do the import graph.
Remove PkgPath.
Remove the DisableCgo option.
Rename some fields of Package:
  Srcs -> GoFiles
  OtherSrcs -> OtherFiles
  Type -> Types
  Files -> Syntax
  Info -> TypesInfo
delete the All function

Change-Id: I54e5dc3ca5cb0b7e33fe6aa6f70cc66e18ea8cac
Reviewed-on: https://go-review.googlesource.com/125535
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-25 00:10:29 +00:00
Ian Cottrell
ded554d068 go/packages: splitting the scratch fields out of Package
This makes Package a struct we can re-use in other places/algorithms.

Change-Id: I2e095a624bf44223319ba1ea3d60deb727b38f81
Reviewed-on: https://go-review.googlesource.com/124855
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-23 20:42:46 +00:00
Russ Cox
96ee42108a go/packages: revise documentation
I made a pass through the documentation trying to simplify
and make it more accessible to readers who are unfamiliar
with all the ins and outs of the implementation.

I also added TODOs about things I don't understand
and names that we should think about changing.

Change-Id: I633316bd407f3360eb8a683bc8d85fba93ca381e
Reviewed-on: https://go-review.googlesource.com/125305
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-23 18:30:23 +00:00
Gustav Westling
60ffea201e godoc: correctly parse packages with digits in the package name
Fixes golang/go#26514

Change-Id: I4540737425c225c0f0c6104b5b3524621d2b0c6f
GitHub-Last-Rev: 9d5fefb6ed31579b723293c7f43fcf677ac4cddb
GitHub-Pull-Request: golang/tools#41
Reviewed-on: https://go-review.googlesource.com/125335
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-22 15:00:05 +00:00
Brad Fitzpatrick
99195f4d4f godoc/dl: also serve go-import meta tags at golang.org/dl for cmd/go
Updates golang/go#23223

Change-Id: Iacecbb5e095fd3d6acb3f8e1fb238db63d1e0b6d
Reviewed-on: https://go-review.googlesource.com/125195
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-20 05:57:21 +00:00
Brad Fitzpatrick
827f47db85 godoc/dl: add meta tags for go get golang.org/dl/go1.N
Updates golang/go#23223

Change-Id: I628cea181d3a0e6bb25fdd98e098581aa222e049
Reviewed-on: https://go-review.googlesource.com/123679
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-20 03:34:01 +00:00
Andrew Bonventre
42aedba1e0 godoc/dl: update download link from /x/build/version to /dl
Change-Id: Id2baaa87ab23e27ce5018271c8bb4e73750fb437
Reviewed-on: https://go-review.googlesource.com/125137
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-20 03:31:16 +00:00
Jim Minter
4735f53fb3 cmd/goyacc: append trailing newline to text "Code generated by goyacc"
Fixes golang/go#26478

Change-Id: Ieaf7dcaf639b277555580964acfff034393284e2
GitHub-Last-Rev: f2a6ab2a513d4938cda62f46de7f5314714b5325
GitHub-Pull-Request: golang/tools#39
Reviewed-on: https://go-review.googlesource.com/124995
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-19 18:26:00 +00:00
Michael Matloob
54f9f5980a go/packages: remove Package.IsTest field
We have not yet settled on the meaning of Package.IsTest, and more
deeply which packages are test and which are non test packages.

This change will remove Package.IsTest in the meantime to avoid
confusion. We may later add a boolean or some other way to distinguish
test and non-test packages.

Change-Id: If6b128f7914009fdd42b8bc3de3bff73c8f006cd
Reviewed-on: https://go-review.googlesource.com/124388
Reviewed-by: Russ Cox <rsc@golang.org>
2018-07-19 17:37:31 +00:00
Brad Fitzpatrick
32950ab3be godoc: add version info for struct fields
Follow-up to CL 85396, which only did types, funcs, and methods.

This adds version info to struct fields (in the form of small
comments) if the struct field's version is different from the struct
itself, to minimize how often this fires.

Updates golang/go#5778

Change-Id: I34d60326cbef88c108d5c4ca487eeb98b039b16e
Reviewed-on: https://go-review.googlesource.com/124495
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Devon O'Dell <dhobsd@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-17 23:22:00 +00:00
Devon H. O'Dell
57f659e14d godoc: show version information for stdlib
This change reads $GOROOT/api/go1.*.txt when godoc starts and caches
information about which versions of Go introduce functions, types, and
methods. This information is displayed currently only in HTML output.
Functions, types, and methods introduced as part of Go 1 are not
annotated, as their presence at that version is implied.

This change does not address constants or variables, and completely
ignores the syscall package. The former are future work, the latter is
likely an exercise in futility. In all cases, this is because the story
around displaying the version information is not well developed.

Fixes golang/go#5778

Change-Id: Ieb3cc0da7b18e195bc9c443f14fd8a82e8b2bbf8
Reviewed-on: https://go-review.googlesource.com/85396
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Devon O'Dell <dhobsd@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-17 18:09:30 +00:00
Michael Matloob
d74aaa1f57 go/packages: Options.{Dir,Env} pass-through
This change adds optional Dir string and Env []string options
that are passed through to the build system's metadata query.
As with exec.Cmd, the defaults are inherited from the parent
process.

Options.GOPATH is gone. If the client needs to override
GOPATH, they must use Env, but typically the inherited environment
is correct.

The tests not longer use os.Chdir.

We now guarantee that Package.Srcs are absolute file names.

Added test for Options.Dir and relative patterns.

This is a copy of golang.org/cl/123777, which had a merge conflict.

Change-Id: I301724581f3d8c712ea78fa5ab5cabd909940dca
Reviewed-on: https://go-review.googlesource.com/123777
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-17 15:06:01 +00:00
Brad Fitzpatrick
fd2d2c45eb go/packages: fix/skip some tests making build.golang.org red
Updates golang/go#26387

Change-Id: I5d91f3747b4f17186813d830f24aa510f5cf0060
Reviewed-on: https://go-review.googlesource.com/123957
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-07-14 20:55:45 +00:00
Alan Donovan
18e9dfbf20 go/packages: add Option.Tests bool, which affects pattern expansion
In the go build system, test packages and executables do not have a
name distinct from the package under test; they are implied, so
"go test fmt" means build those packages but "go build fmt" does not.

This change adds a Tests boolean option to indicate that implied
tests are desired during pattern expansion.
It has no effect on build systems that have explicit names
for tests, such as Blaze/Bazel.

The gopackages diagnostic tool now has a -test flag.

Change-Id: I424f343958c4286539e518d5f30067da19a57f3b
Reviewed-on: https://go-review.googlesource.com/123775
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-07-13 17:38:36 +00:00
Alan Donovan
9d3ae49c73 go/packages: report a distinguished ErrGoTooOld error for older go commands
We should add support for older go commands using the multiple-calls
approach of earlier drafts of go/packages.

Also, tag tests for go1.11 to make 1.10 builder happy.

Change-Id: Ia04979528af25cbcd4b4fa5b21cb91d014d530c1
Reviewed-on: https://go-review.googlesource.com/123756
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-13 17:38:21 +00:00