1
0
mirror of https://github.com/golang/go synced 2024-11-19 07:04:43 -07:00
Commit Graph

3139 Commits

Author SHA1 Message Date
Ian Cottrell
cb89afadce imports: drop anything after a non identifier rune in package names
A package name cannot contain a '.' anyway, so this is a mostly likely
internal package name in the presence of a '.' in the import path.
This stops goimports from adding a local alias in places where it is not
needed, for instance in gopkg.in conventions.

Fixes golang/go#29556

Change-Id: I0ab11f2852d7f1dae14457995692760077201c8e
Reviewed-on: https://go-review.googlesource.com/c/157357
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2019-01-30 18:50:28 +00:00
Dmitri Shuralyov
1c3581914d godoc/short: point to new tracking issue for shortlink creation
There's a new dedicated issue tracking this task, point to it instead
of the previous large issue which has been closed by now.

Updates golang/go#29988
Updates golang/go#27205

Change-Id: Ib1443d14a6369322b36cdf8305344a35c421a2e5
Reviewed-on: https://go-review.googlesource.com/c/160377
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-30 17:39:57 +00:00
Josh Bleecher Snyder
a06a922acc imports: update zstdlib to Go 1.12
Change-Id: Ie70c3d060de9c2e5d3404e073bdc20defdc46357
Reviewed-on: https://go-review.googlesource.com/c/160183
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-30 01:50:43 +00:00
Michael Matloob
9cefa6771f go/packages: rename name= query and "disable" it
It was originally added to support goimports, but goimports
is going with another solution. We're going to disable it for
now, but not delete it, so that the goimports code path that
uses it can continue to be tested if and when we want to
use it.

We don't think there are any other users of name= but if
there are, please let us know and we'll work with you to
fix you, or we'll stop or revert this change. Thanks!

Change-Id: I73b7b6c0a5788148af5f3380189055b450f7b45e
Reviewed-on: https://go-review.googlesource.com/c/159702
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2019-01-29 21:16:23 +00:00
Dmitri Shuralyov
0a99049195 go/vcs: remove go.googlesource.com vcsPath entry
This change synchronizes the absence of a special case entry for
go.googlesource.com import paths in cmd/go/internal/get to this
package. It seems it was added to x/tools/go/vcs in CL 180540043,
but it was never added to cmd/go/internal/get itself.

Having an go.googlesource.com entry here but not in cmd/go/internal/get
means the import path resolution logic diverges from that of the go
command, which is counter to the goal of this package.

After this change is applied, vcs.RepoRootForImportPathStatic reports
correct results for import paths like "go.googlesource.com/scratch.git"
(resolving it without an error) and "go.googlesource.com/scratch"
(reporting an error).

Updates golang/go#11490

Change-Id: I0b1c959675d9e20205a587a06d734fcd103ebf91
Reviewed-on: https://go-review.googlesource.com/c/159817
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-28 23:20:29 +00:00
Michael Matloob
3c4dfba64b cmd/heapview: delete
This is all dead code that never went anywhere.

Change-Id: I79db05d6391709bb9ae3d86f557246f1dd3b21f7
Reviewed-on: https://go-review.googlesource.com/c/159957
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-28 22:39:01 +00:00
Andrew Bonventre
d66bd3c5d5 cmd/godoc: add x/xerrors redirect
Change-Id: I367caa5f8c90e53768b07427248ed2bcc83a58e3
Reviewed-on: https://go-review.googlesource.com/c/159739
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-01-25 23:20:54 +00:00
Ian Cottrell
cc6a436ffe internal/lsp: refactor definition and hover to share functionality
The source package now exposes an Identifier method that returns information
about an identifier, which can be used to implement Definition, TypeDefinition
and Hover, as well as other command line functions in a later cl.

Change-Id: I03629c2c940215b4e2c86ee45bee8a18b79ee0e1
Reviewed-on: https://go-review.googlesource.com/c/159337
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-01-24 21:53:03 +00:00
Douglas Danger Manley
4e3518700c go/packages: stop parsing files if the context is canceled
`stamblerre/gocode`, which is the fork of `mdempsky/gocode` that supports Go 1.11 modules, uses `packages.Load` to load all of the Go code for, among other things, IDE autocomplete support.  A common aspect to IDE autocomplete is asking for suggestions very frequently (perhaps at every character typed).  Once the user has typed another character, the previous request for autocomplete is invalid and can be canceled.

`packages.Load` already stops its `go list` component if the context is canceled, but if the context is canceled afterward, then it will parse all of the files that it found.  This change stops the parsing of Go files once it detects that the context has been canceled.  When a file has not been processed due to cancelation, its error will be set to that of the context.

This change dramatically improves the performance of the `stamblerre/gocode` fork when requests have been canceled.

Change-Id: Iba8c1e08eefa59137559ac9108238bfe5ba4ac21
GitHub-Last-Rev: 11a2210c8ce2ed9db9462ddc3e9676476f49f937
GitHub-Pull-Request: golang/tools#72
Reviewed-on: https://go-review.googlesource.com/c/159259
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-24 20:56:45 +00:00
Michael Matloob
a78a3054ec go/analysis/passes/composite: add an example to the doc
Change-Id: I929a5390aa5f4a4484e57ffa1eaa66f3238da1c1
Reviewed-on: https://go-review.googlesource.com/c/159338
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-01-24 19:20:49 +00:00
Ian Cottrell
78ee07aa94 cmd/gopls/integration: git ignore temporary vscode files
Change-Id: I9585fb227f44c4bf8071247bb6b89b6fed6cf83b
Reviewed-on: https://go-review.googlesource.com/c/159277
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-01-24 00:41:07 +00:00
Julie Qiu
0c44af741b godoc/dl: add julieqiu to validUser
Change-Id: I6b2a49fdae7c45b2b40865c637243402952826af
Reviewed-on: https://go-review.googlesource.com/c/159138
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-23 19:20:57 +00:00
tell-k
85a87a81a9 cmd/present: fix CSS when printing slides
The existing CSS style was causing slides to not align with page
boundaries when printing slides. The cause of that is the CSS transform
property that is applied to automatically scale size of slides.
This change clears the transform property just before printing.

Fixes golang/go#29480

Change-Id: I6f719ad1b716e9bda8ba83007c3d1d7dece9ce08
GitHub-Last-Rev: d46dfee57601b2e9127c5e8e80e596dc2a2f24fa
GitHub-Pull-Request: golang/tools#67
Reviewed-on: https://go-review.googlesource.com/c/155940
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-01-23 18:36:29 +00:00
Dmitri Shuralyov
9279ec27fd cmd/tip: also fetch x/net repository before building cmd/godoc
x/tools/cmd/godoc uses at least one Go package from x/net as of
CL 157197.

Don't add it to signature because we don't want the signature to
change whenever new commits to x/net are pushed, causing tip.golang.org
to be redeployed. This is because x/net is not considered a critical
component of the website at this time, and that's not expected to
change soon.

When the website begins using modules, it will specify the x/net
version precisely and this decision will no longer matter.

Fixes golang/go#29874

Change-Id: I1fa76bb81f8d2ffc2314375e2dfe4898c3af58de
Reviewed-on: https://go-review.googlesource.com/c/158937
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-23 02:11:25 +00:00
Heschi Kreinick
9c309ee22f imports: stop using go/packages for modules
go/packages needs to call `go list` multiple times, which causes
redundant work and slows down goimports. If we reimplement `go list` in
memory, we can reuse state, saving time. `go list` also does work we
don't really need, like adding stuff to go.mod, and skipping that saves
more time.

We start with `go list -m`, which does MVS and such. The remaining work
is mostly mapping import paths and directories through the in-scope
modules to make sure we're giving the right answers. Unfortunately this
is quite subtle, and I don't know where all the traps are. I did my
best.

cmd/go already has tests for `go list`, of course, and packagestest is
not well suited to tests of this complexity. So I ripped off the script
tests in cmd/go that seemed relevant and made sure that our logic
returns the right stuff in each case. I'm sure that there are more cases
to cover, but this hit all the stuff I knew about and quite a bit I
didn't.

Since we may want to use the go/packages code path in the future, e.g.
for Bazel, I left that in place. It won't be used unless the magic env
var is set.

Files in internal and imports/testdata/mod were copied verbatim from
cmd/go.

Change-Id: I1248d99c400c1a0c7ef180d4460b9b8a3db0246b
Reviewed-on: https://go-review.googlesource.com/c/158097
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-22 20:29:12 +00:00
Andzej Maciusovic
2d2e1b1749 internal/lsp: do not complete inside comments in functions
The previous change (https://go-review.googlesource.com/c/tools/+/157678) only stopped completion in comments in global scope. This change prevents completions results from being sent for comments inside of functions.

Fixes golang/go#29370

Change-Id: I2b43ae2942c6ce7376d2a5f88c40e6ac45c2b773
GitHub-Last-Rev: bc4aac1370aa5758941cdfae63290f061a55e204
GitHub-Pull-Request: golang/tools#71
Reviewed-on: https://go-review.googlesource.com/c/158538
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-01-22 18:08:10 +00:00
Ian Lance Taylor
b2f1847864 go/analysis/internal/checker: correct comment grammar
Change-Id: I78b41326c5d8d22fbff40f89721ac3aad3a5c63c
Reviewed-on: https://go-review.googlesource.com/c/158841
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-22 15:45:57 +00:00
Aurélien Rainone
24cd39ecf7 go/analysis/passes/atomicalign: add atomicalign ckecker
The atomicalign Analyzer checks the alignment of 64-bits variables
accessed atomically via sync/atomic functions on 32-bits
architectures. Per the sync/atomic BUG note those variables must
be 64-bits aligned, otherwise a runtime panic is issued.

The analyzer only shows and runs on 32-bits architectures.

This CL should not introduce any false positives.

Add some tests in testdata/src/a to verify the analyzer behavior
on affected architectures plus some very basic test to verify that
no warning is generated on non-affected ones.

Fixes golang/go#11891

Change-Id: I02cfc574883564cd2a213a92d33bda3cc9a1ea98
Reviewed-on: https://go-review.googlesource.com/c/158277
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-01-21 14:31:47 +00:00
Heschi Kreinick
16909d206f imports: remove globals, stop using build.Default
The imports package's public API is build.Default, but that doesn't mean
we need to use it in the internal implementation or the tests. Now we
have a new type, fixEnv, that contains everything relevant from
build.Context, as well as the various global vars that were only used
for testing.

Don't worry too much about the new function parameters; they mostly
move into the resolvers in the next CL.

Refactoring only; no user-visible changes intended.

Change-Id: I0d4c904955c5854dcdf904009cb3413c734baf88
Reviewed-on: https://go-review.googlesource.com/c/158437
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-18 19:33:59 +00:00
Heschi Kreinick
6466e7265e imports: don't eagerly guess package names
Before this change, we guessed package names during loadPackageNames
when necessary. That made it impossible to tell if we failed to load
a package's name, e.g. because its source code is unavailable. That
interferes with fixes for golang/go#29557. It also meant that each
implementation of package name loading needs to do the guessing,
which gets annoying in CL 158097.

Instead, leave package names unset unless we're certain about them, and
guess only in (*pass).importIdentifier when necessary.

Refactoring only; no user-visible changes intended.

Change-Id: Ia6072ada823e6e3a86981ad90228f30baa2ac708
Reviewed-on: https://go-review.googlesource.com/c/158199
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-18 19:13:21 +00:00
Alan Donovan
b4b6fe2cb8 go/{analysis,packages}: add TypesSizes
Many Analyzers need to measure the width of an integer and all today
use hacks. This change causes analysis.Pass to retain and expose the
type sizing function used during type checking.

This in turn requires go/packages to retain and expose the type sizing
function in Packages.TypesSizes, which addresses a longstanding need
among many of its clients.

Change-Id: Ia8362019bcde34c10cb4fbc38cfdfddcbef3eb5c
Reviewed-on: https://go-review.googlesource.com/c/158317
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2019-01-17 19:41:23 +00:00
Rebecca Stambler
b258f6da23 cmd/gopls: rename "golsp" to "gopls", as in "Go Please"
Change-Id: Ie5688759ce21bffa6745eb86ef3606639e3ce335
Reviewed-on: https://go-review.googlesource.com/c/158197
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-16 23:16:16 +00:00
Daniel Martí
c3e1567727 go/packages: make tests pass with custom GOCACHE
This commit was merged earlier with some failing trybots, so it was
reverted. This is a re-submission.

Before this change, a test would fail:

	$ GOCACHE=$HOME/go/cache go test
	--- FAIL: TestLoadImportsGraph (0.36s)
	    --- FAIL: TestLoadImportsGraph/GOPATH (0.19s)
		packages_test.go:191: golang.org/fake/subdir/d.test.Srcs = [4302876da86a8aae0c1669924daa223cafca60ef49ccaa060ae37e778d18f218-d], want [0.go]
	    --- FAIL: TestLoadImportsGraph/Modules (0.17s)
		packages_test.go:191: golang.org/fake/subdir/d.test.Srcs = [4302876da86a8aae0c1669924daa223cafca60ef49ccaa060ae37e778d18f218-d], want [0.go]
	FAIL

This is because it assumed that the user hadn't set their own GOCACHE,
and thus that all source files in the cache would be under the default
"go-build" cache directory.

We could fix this via os.Getenv("GOCACHE"), but a simpler mechanism is
to see if the source file has an extension. Source files don't have an
extension in GOCACHE, so that's much simpler to detect.

After this change:

	$ GOCACHE=$HOME/go/cache go test
	PASS

golist_fallback.go also had a bit of code to add "/go-build/" to the
added testmain.go path, to trick the tests on Go 1.10 to think the file
was in GOCACHE. Update that code too, to now not add ".go" to the path
instead.

While at it, gofmt.

Fixes golang/go#29445.

Change-Id: I21fc59f13f00bea1f9a8a80e0438825f1a36ac3e
Reviewed-on: https://go-review.googlesource.com/c/156977
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-01-16 20:24:37 +00:00
Andzej Maciusovic
f94e9803bf internal/lsp: do not complete inside comments
Fixes golang/go#29370

Change-Id: I160b00f95fe44b2d87f66dc5842bb3a124e0292c
GitHub-Last-Rev: 924c13bc86f947ca01b291e7cc0d171164c2c856
GitHub-Pull-Request: golang/tools#69
Reviewed-on: https://go-review.googlesource.com/c/157678
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-01-16 17:22:44 +00:00
Rebecca Stambler
2e4132e53b internal/lsp: add a test for completion of builtin types and functions
Change-Id: I7df2cfebbf2c44d189066a6d16770c753f7bf1d4
Reviewed-on: https://go-review.googlesource.com/c/158020
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-16 00:24:28 +00:00
Rebecca Stambler
bf090417da internal/lsp: fix a few nil pointer exceptions in definition
Jumping to the definition of a builtin function or basic kind would
cause a nil pointer because these have no position.

Change-Id: I043a61a148757b127ff1123c8429ce23858bd13a
Reviewed-on: https://go-review.googlesource.com/c/157597
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-01-14 22:23:45 +00:00
Dmitri Shuralyov
36f37f8f5c go/packages: rename Illtyped to IllTyped in docs
Fix the field name in docs to have the correct case, as seen at
https://godoc.org/golang.org/x/tools/go/packages#Package.IllTyped.

Change-Id: I3184c2fc5f9c4641a61dbd2af6a11309e9f284ea
Reviewed-on: https://go-review.googlesource.com/c/157797
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-01-14 16:46:48 +00:00
Rebecca Stambler
fc1d57b08d cmd/golsp: add a debugging tool to connect with golsp on a port
This change allows golsp to be run on a port, with an intermediary
command passing the data through. This allows for improved logging.
Also, add necessary changes to VSCode integration to allow changing the
name of the command for golsp.

Change-Id: I20dca1a50296636e57e022342ee70f0610ad1531
Reviewed-on: https://go-review.googlesource.com/c/157497
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-11 21:44:48 +00:00
Dmitri Shuralyov
4b7be70d8a godoc/dl: don't display unstable releases under archive
If a release is unstable, don't consider adding it to archive or stable
lists as well. It should be present in the unstable list only.

Create and use test helper list to make tests more compact and thorough.

Also use a more consistent order of got, want in TestFilesToReleases.

Fixes golang/go#29669

Change-Id: I74cf1fa8ebf05b13a3a4c40b53442c50e0427302
Reviewed-on: https://go-review.googlesource.com/c/157499
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-11 18:10:22 +00:00
Agniva De Sarker
40c2d4768f go/analysis: fix typos and update documentation
Change-Id: I48187fcb1eedd5b94d7b6b2db1ae11009bab23a2
Reviewed-on: https://go-review.googlesource.com/c/157299
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-01-11 18:03:38 +00:00
Daniel Martí
68c5ac90f5 go/packages: Load with no patterns should load "."
At least on the go list driver, which is the default fallback. Note that
we need to call 'go list' on Load("foo") and Load(), but not
Load("name=bar"). This is what the current logic was trying to
accomplish.

But it didn't take into account the case where there are zero initial
patterns, in which case we should still call 'go list'. Fix that, and
add a test.

Fixes #28767.

Change-Id: I40af9eb7f2407449c5683df1403928e2c57c86a4
Reviewed-on: https://go-review.googlesource.com/c/155898
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-10 21:10:28 +00:00
Yasuhiro Matsumoto
a2c791aa64 internal/lsp/cache: return error when no packages found
Change-Id: Ia11f0c428cffdd42eab5c4322e9ff6f0a38870fc
Reviewed-on: https://go-review.googlesource.com/c/156777
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-10 19:47:25 +00:00
Michael Matloob
51295c7ec1 go/packages: update comment on when golist fallback triggers
It triggers for all go versions before 1.11. We thought we might
be able to backport some of the necessary changes to 1.10.4, but
it was infeasible, so no 1.10.x versions will support the non-fallback
behavior.

Change-Id: Ib22be2715bf504464e4bd09c14453e5d132776f3
Reviewed-on: https://go-review.googlesource.com/c/156898
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-10 16:31:46 +00:00
Agniva De Sarker
158f3dcaf6 go/ast/inspector: fix a small typo
Change-Id: Ifa677f0b0cd1cc345ce65eceacae4413a5644646
Reviewed-on: https://go-review.googlesource.com/c/157300
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-10 14:16:07 +00:00
Dmitri Shuralyov
aa03309574 godoc/redirect: display Gerrit/Rietveld CL disambiguation page when needed
For CL numbers that are determined to be Rietveld CLs, instead of
immediately redirecting, check whether a Gerrit CL with the same
number also exists. Do so by querying the Gerrit API and caching
the existing CLs. If both exist, display a very simple disambiguation
HTML page.

Cache Gerrit CLs that exist, to avoid querying the remote API server
more than once per CL. We can't cache Gerrit CLs that don't exist,
since they might get created in the future.

Fixes golang/go#28836

Change-Id: I08c32dc82a0136788337c5c32028e87428e8d81e
Reviewed-on: https://go-review.googlesource.com/c/157197
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-10 01:58:56 +00:00
David Chase
d30e00c240 splitdwarf: initial working commit
splitdwarf osxMachoFile [ osxDsymFile ]

splitdwarf takes an executable produced by go build as input,
and uncompresses and copies the DWARF segment into a separate
file in the way that is expected by OSX-hosted tools
(lldb and ports of gdb).
If osxDsymFile is not named explicitly, the default of
"<osxMachoFile>.dSYM/Contents/Resources/DWARF/<osxMachoFile>"
is used instead, with directories created as needed.

If the input file contains no UUID, then one is created by
hashing non-DWARF segment contents, and added to the
executable. This is necessary because gdb and lldb both
expect matching UUIDs to be present in the executable
and its debugging symbols.

Includes a modified version of debug/macho, with additional
definitions and the ability to write segments, sections, and
some MachO load commands added.

Change-Id: Ia5b0e289260f72bbca392cdf2c7c0a75e3ca40e5
Reviewed-on: https://go-review.googlesource.com/c/143357
Reviewed-by: Austin Clements <austin@google.com>
2019-01-09 16:56:30 +00:00
David Chase
d674b4ad67 cmd/splitdwarf: copy debug/macho
The splitdwarf command will need a modified version of debug/macho.
This is a verbatim copy from std as of Go 1.11, which we'll modify in
the next CL.

Change-Id: Ia9ded870d1ba91dad21f9f6dc5bb38f9f6cc0e80
Reviewed-on: https://go-review.googlesource.com/c/152240
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
2019-01-09 16:55:59 +00:00
Peter Weinberger
98df4c70be tools/internal/lsp/protocol: add LocationLink type
LocationLink was added in 3.14.0 of lsp.

Change-Id: I388dba5ab43b195cc3965e4199b49155094a2627
Reviewed-on: https://go-review.googlesource.com/c/156617
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-09 16:41:58 +00:00
Michael Matloob
421f03a57a Revert "go/packages: make tests pass with custom GOCACHE"
This reverts commit e7b5a6dfd8.

Reason for revert: merged by mistake

Change-Id: Ibf6ff4aa346b569aaa5e06b58770a93ca3eebdab
Reviewed-on: https://go-review.googlesource.com/c/156900
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-01-08 22:28:58 +00:00
fREW Schmidt
e8d59ebc66 Remove warning stability warning
December 1, 2018 has come and gone.

If the timeframe should change that's fine; feel free to reject this and just update the date.

Change-Id: If6aaee30340ee0bfde7e578e054c5b8bc910a5b9
GitHub-Last-Rev: ec781ca1374a010168bc4a457d2ea5d0c023f8dc
GitHub-Pull-Request: golang/tools#64
Reviewed-on: https://go-review.googlesource.com/c/155237
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-01-08 19:38:35 +00:00
Steven L
5e40c1c236 go/analysis/internal/checker: don't clobber error when packages.Load fails
Previously, if `packages.Load` failed, it would (sometimes? always?) return an error + no initial packages.
The moved `len(initial)` check was overriding the actual err with a much less useful one.

Example output before:
```
13:03:17.856866 load [./...]
13:03:28.403532 ./... matched no packages
```
And after:
```
13:03:30.942191 load [./...]
13:03:36.999506 go list repeated package [an internal package] with different values
```

Change-Id: I1a821e3855cbbbee904bcec9c29877e091c3e3a0
GitHub-Last-Rev: d1235fc2eceb0d4e947f47be99edc5ac96da5f84
GitHub-Pull-Request: golang/tools#65
Reviewed-on: https://go-review.googlesource.com/c/155745
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-01-08 19:37:22 +00:00
Daniel Martí
e7b5a6dfd8 go/packages: make tests pass with custom GOCACHE
Before this change, a test would fail:

	$ GOCACHE=$HOME/go/cache go test
	--- FAIL: TestLoadImportsGraph (0.36s)
	    --- FAIL: TestLoadImportsGraph/GOPATH (0.19s)
		packages_test.go:191: golang.org/fake/subdir/d.test.Srcs = [4302876da86a8aae0c1669924daa223cafca60ef49ccaa060ae37e778d18f218-d], want [0.go]
	    --- FAIL: TestLoadImportsGraph/Modules (0.17s)
		packages_test.go:191: golang.org/fake/subdir/d.test.Srcs = [4302876da86a8aae0c1669924daa223cafca60ef49ccaa060ae37e778d18f218-d], want [0.go]
	FAIL

This is because it assumed that the user hadn't set their own GOCACHE,
and thus that all source files in the cache would be under the default
"go-build" cache directory.

We could fix this via os.Getenv("GOCACHE"), but a simpler mechanism is
to see if the source file has an extension. Source files don't have an
extension in GOCACHE, so that's much simpler to detect.

After this change:

	$ GOCACHE=$HOME/go/cache go test
	PASS

While at it, gofmt.

Fixes #29445.

Change-Id: I83c0afc20a527bb50a03f9946e555db36cc85efd
Reviewed-on: https://go-review.googlesource.com/c/155897
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-01-08 19:35:00 +00:00
Zac Bergquist
1bc491975c go/packages: update doc for name= queries
Change-Id: I2ba387703ae1f31e7dff271007607f377701f7dd
Reviewed-on: https://go-review.googlesource.com/c/155941
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-01-08 19:25:35 +00:00
Ian Cottrell
7cb465e007 go/package/gopackages: update gopackages to use the new tool library for its main function
Change-Id: I06f13024c021d14e4a759ca9ec24aa54f9d1b97f
Reviewed-on: https://go-review.googlesource.com/c/154558
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-01-08 19:17:02 +00:00
Daniel Martí
e063def13b go/analysis: fix package doc copy-paste typo
Change-Id: I17495106c76bbf270f621abe2eca367ed818a79b
Reviewed-on: https://go-review.googlesource.com/c/156500
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-07 15:52:54 +00:00
Emil Hessman
d345f29b0d internal/lsp: fix typo
Change-Id: I04164ea5b57ebb828ecb837caa397c9e736f4d57
Reviewed-on: https://go-review.googlesource.com/c/156457
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-07 03:02:06 +00:00
Daniel Martí
3ef6863234 go/analysis: fix ambiguous paths in structtag pass
Now that we support checking for duplicate struct field tags across
anonymous struct fields, we must deal with the fact that the files
involved in such a warning may not be in the same package or directory.

This could lead to errors where a file was mentioned in a package where
it didn't exist. Or even worse, point at a location within an existing
file that doesn't contain the field we want, causing even further
confusion to the user.

To fix this, always make the "also at" positions relative to the current
warning, if possible.

Fixes #29130.

Change-Id: Iaa29b406978f1671bdfb2ddddb7058eeffec92a9
Reviewed-on: https://go-review.googlesource.com/c/155899
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-01-06 17:17:56 +00:00
Heschi Kreinick
498d954934 go/packages/packagestest: make temp directory writeable
In module mode, the temp dir will contain a mod cache, which needs to be
made writeable before it can be deleted.

Change-Id: Ia979a8b06d1b4db47d25ffdfdf925ba8a0ac67de
Reviewed-on: https://go-review.googlesource.com/c/156078
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-04 18:20:27 +00:00
Dmitri Shuralyov
9ea1c200b2 cmd/godoc: add x/website redirect
Add a redirect for the recently created x/website subrepository.

It's not yet included at https://golang.org/pkg/#subrepo because it's
in development. Once development reaches the point that x/website
is the canonical location of the golang.org server, we can consider
including x/website at https://golang.org/pkg/#subrepo (just like
x/blog, x/tour, x/build are already included there).

Updates golang/go#29206

Change-Id: I6889c1f5e40f11abca944b217a7354f76c08c8eb
Reviewed-on: https://go-review.googlesource.com/c/156337
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-04 17:33:42 +00:00
Heschi Kreinick
8a60511975 imports: don't look for, or find, empty packages
Fix a pair of bugs that combined to cause golang/go#29520. First, don't go
looking for a package if we've only seen unexported identifiers selected
from it. It's probably a typo. Second, don't find packages with no files
in them, e.g. because they're all build tagged out. We can't know what
package they form, so we have no business considering them.

Test only for the first, since without the first bug the second has no
observable effect on behavior, and I don't want to test the private API.

Fixes golang/go#29520

Change-Id: I5b797940bec051be5945b9c5cb4e7bf28527a939
Reviewed-on: https://go-review.googlesource.com/c/156178
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-03 20:59:43 +00:00