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

2666 Commits

Author SHA1 Message Date
Heschi Kreinick
00c5fa5868 go/packages: find mismatched top level packages in name=
Treat the top-level package of a module specially so that the VCS
working dir name doesn't have to match the package name. Generally we
take the position that directory names should match packages, but for
the top-level package that's a pretty strict requirement. Now we always
check the top-level directory, just in case.

Change-Id: I2e96751bf46736fbaef434fa9788fdc1339c37b9
Reviewed-on: https://go-review.googlesource.com/c/144817
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-30 00:03:57 +00:00
Ian Cottrell
2d2de62981 go/packages: sort root list in Load
The builders are currently flaky failing because of a root order being
wrong.
This causes all root lists to be sorted before being returned, so the
order is always stable no matter which underlying driver is running.

Fixes golang/go#27594

Change-Id: I09db45c67ad00f23dfaec8e271acbd13fc338888
Reviewed-on: https://go-review.googlesource.com/c/143737
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-29 18:14:17 +00:00
Alan Donovan
9aea6da185 go/analysis/internal/facts: fact serialization support
Package facts provides an implementation of the Import/Export methods
of the analysis.Pass interface and functions to encode and decode
facts, using Gob encoding, to a file. It will be part of the vet-lite
driver (invoked by go vet) but the same logic has been validated in
other build systems such as Blaze.

Change-Id: I60ef561e84e833b9a3b17c269ab358e7d0800ff3
Reviewed-on: https://go-review.googlesource.com/c/144737
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-10-29 17:32:15 +00:00
Heschi Kreinick
f60e5f99f0 go/packages/packagestest: use a module proxy
Instead of writing replace directives to link the test's modules
together, fill a GOPROXY dir and use `go mod download` to fill a real
GOCACHE with them. This makes the tests more realistic, since replace
directives will be somewhat unusual. It also gives the name= query
something to search.

Actually doing this in a way that's compatible with packagestest's
abstraction is a little tricky, since it wants to know where the files
will be. The actual files will be created by go mod download, so we have
to get Export to put them there to begin with, then move them out of the
way.

Since the GOPROXY zip format doesn't support symlinks, those will only
work in the primary module.

Change-Id: I6bc1d368f1c950d789e409213107d60bb1389802
Reviewed-on: https://go-review.googlesource.com/c/144498
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-10-26 18:38:34 +00:00
Heschi Kreinick
e74f1bd585 imports: port tests to packagestest
I tried to introduce new modules where it made sense. I deleted the
weird goroot test because I removed the optimization it was testing in
an earlier CL.

Change-Id: I219ddaa4f462a4aeb640f62215d16f246511a5fe
Reviewed-on: https://go-review.googlesource.com/c/144497
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-26 18:23:19 +00:00
Brad Fitzpatrick
a2dc47679d Revert "imports: support repairing import grouping/ordering"
This reverts commit CL 116795 12a7c317e8.

Reason for revert: mangles comments in imports. See comments
on issue golang/go#20818.

Updates golang/go#20818

Change-Id: Iff82f8dc310dceb982b48d82b26176ea279fef10
Reviewed-on: https://go-review.googlesource.com/c/144339
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-10-24 17:12:08 +00:00
Hana Kim
40a48ad93f godoc: replace x/net/context with context
Change-Id: I5b0508ccf7a912a8f334abcfb32033e120fc7971
Reviewed-on: https://go-review.googlesource.com/c/143717
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-23 01:05:39 +00:00
Rebecca Stambler
9650c66da3 internal/lsp: add support for publishing diagnostics
Any time a file is changed, we compute diagnostics for its package and
return them to the client. No caching is implemented yet, so we parse
and type-check the package each time.

Change-Id: I7fb2f1d8975e7ce092938d903599188cc2132512
Reviewed-on: https://go-review.googlesource.com/c/143497
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-22 21:17:51 +00:00
Dmitri Shuralyov
6fe81c0879 present: remove mention of non-existing emphasis toggle
To find out whether the documentation was wrong, or if the
implementation had a bug, I did some code archeology. The earliest
commit I found where the 'h' key in browser was mentioned was the
very first commit where the present format is added. It was in talks
subrepo before being moved to tools subrepo. It was CL 6497063.

In that commit, I see no mention of 'h' key anywhere else except
that one line of documentation.

Three years later, the 'h' key got mapped to hiding the help dialog
in CL 4910.

My best guess is this original feature was documented but
never implemented. So removing it from documentation is
the most appropriate fix.

Fixes golang/go#17375.

Change-Id: Ibe0b39d73a7a0652acd6a04beddfcff22b0e3c4a
Reviewed-on: https://go-review.googlesource.com/c/143557
Reviewed-by: Andrew Gerrand <adg@golang.org>
2018-10-22 17:16:10 +00:00
Ian Cottrell
c5032d394f go/packages: Fixes for bad wd handling
Darwin convertes the working directory to a real path which affects the
path a command is started with when you exec.
This causes a problem where the path the go list command is run with
does not match the path the outside program is trying to use, which
causes both undesirably changed paths in it's outputs, and sometimes
failures to cope with modules when source files are "outside" the module
root.
The go standard library has a special feature in os.Getwd where it
checks if the PWD environment variable is the same inode as the system
cwd, and if it is it returns the PWD instead. This change deliberately
sets the PWD before running go list so that behaviour is triggered,
which fixes all the paths.
This was breaking the mac build bots in a goimports test, it should be
fixed now.

Change-Id: I0f5d3c7d020b55749738036ba51c19884bb26598
Reviewed-on: https://go-review.googlesource.com/c/143517
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-10-22 15:13:45 +00:00
Agniva De Sarker
3e7aa9e599 godoc: generate TOC from server-side for search page
Currently, we generate the TOC for a page dynamically after page load
through javascript. This is fine for pages with static content.

But for pages with dynamic output like /search, sometimes this causes a
noticeable page jump due to extensive DOM traversal. Also, the heuristics
to calculate the no. of columns is very rudimentary and fills the entire
above-the-fold area if the no. of results is very large.

Therefore, we generate the TOC from server side itself. And improve
the no. of columns heuristic further to accomodate up to 4 columns.

This improves page performance and utilizes real estate appropriately
according to the input.

Some screenshots at laptop (1366x768) resolution.
https://snag.gy/AXz2rP.jpg
https://snag.gy/th3Nn8.jpg

More can be found in the CL comments.

Fixes golang/go#21685
Updates golang/go#21686

Change-Id: Ia9b6dd1e67231d992709e4ba10ebdbedfe38b564
Reviewed-on: https://go-review.googlesource.com/c/129135
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-10-19 20:12:13 +00:00
Alan Donovan
26c26290c3 go/*: fix pre-1.11 tests
packagestest.Modules is now available pre-go1.11 but doesn't add
itself to packagestest.All.

strings.ReplaceAll is not available in pre-go1.11

Change-Id: Ia8bf0e82bb853c6f29d31ca5c54651097342b19c
Reviewed-on: https://go-review.googlesource.com/c/143419
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-10-19 19:11:07 +00:00
Alan Donovan
9545aa7b51 go/analysis/cmd/vet: new name for cmd/analyze
This is the new vet command. It can be run standalone:

	$ vet my/project/...

or (soon) under go vet:

	$ GOVETTOOL=$(which vet) go vet my/project/...

A forthcoming CL will add support for the second mode, and define a
vet-lite command that supports only that mode, but has fewer
dependencies; it is intended to be vendored into $GOROOT/src/cmd/vet.

Change-Id: I57696ae6d43aa31fd10b370247b7e7497f0f3597
Reviewed-on: https://go-review.googlesource.com/c/143417
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2018-10-19 18:46:07 +00:00
Robert Griesemer
5efdaf2100 go/internal/gcimporter: update gcimporter.go to incorporate std lib changes
This CL brings over changes from https://golang.org/cl/74354/
which were not brought over.

The code was adjusted slightly such that a filename is still available
for ImportData even if a custom lookup function is provided (adjustments
are on lines 133, 188-193).

Change-Id: I58960e648c9aae1683eb4d7f8d7578f09349eca2
Reviewed-on: https://go-review.googlesource.com/c/143017
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-10-19 17:52:01 +00:00
Robert Griesemer
a53bc13a63 go/internal/gcimporter: remove support for Go versions < Go 1.10
- eliminated special case for isAlias predicate
- appended code from bexport19_test.go to bexport_test.go

No other changes.

Change-Id: Icf10691510e51f4e618b2a48bc1a1215a98832b6
Reviewed-on: https://go-review.googlesource.com/c/142896
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-10-19 17:49:27 +00:00
Alan Donovan
a019f6b7c5 go/analysis/internal/analysisflags: common flag handling
The analysisflags package provides a function to help
ensure that all drivers support consistent command-line
interfaces.  In particular, -analyzer.enable flags use
tristate logic as in vet, and the -flags flag dumps
a list of flags in JSON for use by 'go vet' and other
build systems.

This code is in a separate package from internal/checker
(the common parts of multichecker, singlechecker)
because we don't want the forthcoming vet-lite (formerly
known as doctor) driver to have an unnecessary dependency
on go/packages.  (When go/packages is promoted to the
standard library we can consolidate them.)

+ Test of tristate analyzer selection logic.

Change-Id: I5ea4e556e0f56505df06eb8fa9dd9eed884a1b47
Reviewed-on: https://go-review.googlesource.com/c/143197
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-19 17:43:12 +00:00
Alan Donovan
45f20876fc go/analysis/passes/shadow: adapt for analysis API
Change-Id: I9b7c98ab9647e17c286e656860038498e32f99f2
Reviewed-on: https://go-review.googlesource.com/c/142358
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-19 17:13:52 +00:00
Alan Donovan
4805105a3a go/analysis: doc: explain how to report diagnostics in raw text files
Change-Id: I6b31e6f4b61948e459faf5a1ada18de69741b947
Reviewed-on: https://go-review.googlesource.com/c/143299
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-19 17:04:33 +00:00
Alan Donovan
8dacc032e7 go/analysis/cmd/analyze: install all analyzers
The default value of -findcall.name has been changed to ""
to avoid producing noise.

Change-Id: I71554080bcc7b6e23f632b49e30590fa0b0bc034
Reviewed-on: https://go-review.googlesource.com/c/143297
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2018-10-19 17:03:54 +00:00
Alan Donovan
9f76e5c58b go/analysis/passes/vet: delete
All the passes have been moved into their own packages.

The README file has been saved for the new cmd/analyze command,
which will shortly be renamed to vet.

Change-Id: I68c765a4da2f8d5a2b0161b462bd81483b5ceed5
Reviewed-on: https://go-review.googlesource.com/c/143301
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-19 16:58:18 +00:00
Alan Donovan
19100bfbe9 go/analysis/passes/asmdecl: fix nil deref panic
Due to a bug in go/types, a function f(...T) has no type
recorded for the parameter type expression ...T, and apparently
this has never occcured in a file checked by asmdecl before.

The addParams function should really be simplified to use types.Signature.

Updates golang/go#28277

Change-Id: I5b73535a7739b6771ffef1c0a7568f5161d564d5
Reviewed-on: https://go-review.googlesource.com/c/143298
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-19 16:56:31 +00:00
Alan Donovan
327a9b56d0 go/analysis/passes/tests: add testcase from vet
vet's "divergent" testdata package exercises various mistakes
in naming Example functions.

vet's "incomplete" testdata package has been deleted because
it is no longer applicable. It was intended to ensure that a
x_test.go file specified on its own would not trigger false
positives without the corresponding x.go files, but the
new Analysis API always analysis complete packages.

Change-Id: I1a40ead340c806b571302fdaa537f481514b0c22
Reviewed-on: https://go-review.googlesource.com/c/143300
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2018-10-19 16:56:12 +00:00
Alan Donovan
6adeb8aab2 go/analysis/passes/nilness: degenerate nil condition checker
This check uses the control-flow graph and SSA value graph to detect
problems such as:

	p := &v
	...
	if p != nil { // tautological condition
	}

and:

	if p == nil {
		print(*p) // nil dereference
	}

(It was originally developed within Google's Go analysis framework and
can now be published in a form useful to all analysis drivers.)

This CL also includes buildssa, an Analyzer that constructs SSA for
later analysis passes but does not report diagnostics or facts of its
own.

Change-Id: I27bc4eea10d71d958685a403234879112c21f433
Reviewed-on: https://go-review.googlesource.com/c/142698
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-19 00:59:45 +00:00
Agniva De Sarker
def2677374 cmd/godoc: cleanup documentation for CLI mode
- Removed all documentation which referred to godoc's CLI capabilities.
- Added some missing flags which were not documented.
- Removed some redundant mentions of "web server" because now it is
just a web server.
- Converted some links to https

Change-Id: I7ddcf417d2bc3df13183adcfd0f82af9a37a1b91
Reviewed-on: https://go-review.googlesource.com/c/143077
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-18 18:24:39 +00:00
Ian Cottrell
06f26fdaaa go/packages/packagestest: Testing with multiple drivers
This extracts some of the test code from packages, and adds the ability to run
the same test with multiple drivers.
This should generally be useful for all tools that run on top of go/packages as
well when writing tests for them.

Change-Id: I88c596ad07c0782270c5798d92ae29f7549943cf
Reviewed-on: https://go-review.googlesource.com/c/140118
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-17 21:43:49 +00:00
Robert Griesemer
249abec53b go/internal/gccgoimporter: update package to match std lib version
This CL makes sure it matches the original code in the std lib
but for the necessary changes to make the code work in x/tools
and with older versions of the std lib.

Notably, it brings over changes from https://golang.org/cl/119895
which were not ported to x/tools.

To simplify future comparisons with the original, streamlined
some comments.

Fixes golang/go#27891.

Change-Id: Iff48c11cb7f0f8a55b4ea33321c686f9d5c707c7
Reviewed-on: https://go-review.googlesource.com/c/142893
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-10-17 21:20:11 +00:00
Robert Griesemer
9183b65408 go/internal/gccgoimporter: add missing copyright notice
Change-Id: I2a1d5132f7263d8dc0e2a42c42b37b9d962a3ab7
Reviewed-on: https://go-review.googlesource.com/c/142892
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-10-17 21:19:00 +00:00
Heschi Kreinick
4a1b41eed1 go/packages: don't spam stderr
Some editors combine stdout and stderr when running tools, so
printing to stderr without failing confuses them. Stop printing go
list's warnings.

They're still useful for debugging, so users can set
GOPACKAGESPRINTGOLISTERRORS to see them. This isn't part of the API and
has no compatibility guarantees.

Change-Id: I9cf091cf59d082123149888468fa0d126dc972c7
Reviewed-on: https://go-review.googlesource.com/c/142997
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-17 21:05:27 +00:00
Robert Griesemer
7099c87f61 go/internal/gccgoimporter: add missing copyright notice
Change-Id: I20f7aba8a76cfe8549771ef96244e8641a4157e6
Reviewed-on: https://go-review.googlesource.com/c/142891
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-10-17 20:52:59 +00:00
Brad Fitzpatrick
4cdd33fd98 cmd/tip: make tip.golang.org also serve & redirect beta.golang.org to tip
We're turning down the old (and neglected) beta.golang.org godoc VM.
It's not different enough from tip.golang.org, which is more reliable
than it used to be.

Now beta.golang.org will just redirect to tip.

Updates golang/go#25978
Fixes golang/go#21073

Change-Id: Iae7fe4c82c14cec7381e75a2e214210d38b6e623
Reviewed-on: https://go-review.googlesource.com/c/120056
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-10-17 18:38:13 +00:00
Heschi Kreinick
654e6e76cd gopathwalk: don't log for nonexistant root dirs
If users don't have a module cache yet, or put a nonexistant directory
in their GOPATH, it doesn't make sense to print an error. Just ignore it
and move on.

No tests; I don't think it makes sense to set up log scraping for this.

Change-Id: I90719297ade37999e8b401767a0a37c940828c27
Reviewed-on: https://go-review.googlesource.com/c/142977
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-10-17 18:30:23 +00:00
Alan Donovan
e94054f410 go/analysis/passes/composite: add testing.Internal* to whitelist
These structs appear in test main files generated by "go test"
and so can be trusted.

Change-Id: I1514a8cdcbd633392ccaaedfa8eccf944d514129
Reviewed-on: https://go-review.googlesource.com/c/142699
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2018-10-17 15:12:46 +00:00
Heschi Kreinick
5ef16f43e6 go/packages: fix tests on 1.10
Can't do module tests on a pre-modules version of Go.

Change-Id: I8e3e22d472f37ebc9f930a68c9a6c0f4b7ba7ea0
Reviewed-on: https://go-review.googlesource.com/c/142700
Run-TryBot: Heschi Kreinick <heschi@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-16 20:51:53 +00:00
Alan Donovan
a0ecdcbec4 go/analysis/passes: add doc and copyright comments
...and other trivial cleanups.

Multi-line doc comments have been moved to exported Doc constants for
the sake of godoc.

Change-Id: Ib1cbec5806c699d51283c34685c4cd96953f5384
Reviewed-on: https://go-review.googlesource.com/c/142360
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-16 20:28:15 +00:00
Heschi Kreinick
63d31665e3 go/packages: add name= query
Add an implementation of name= for go list. It will be used to
implement goimports and godoc-like lookups by package name.

Imported a copy of the semver package from the stdlib to do version
comparison, and tweaked the gopathwalk API to include a hint about what
kind of source directory is being traversed.

Note that the tests, despite my best efforts, are not hermetic: go list
insists on doing version lookups in situations where it seems to me like
it shouldn't need to.

I think this implementation is ready for serious use. The one thing I'm
nervous about is that it currently does a substring match when looking
for a package name, so if you look up a package named "a" you will get
a huge number of results. This matches goimports' behavior but I don't
know if it's suitable for general use.

Change-Id: I2b7f823b74571fe30d3bd9c7dfafb4e6a40df5d3
Reviewed-on: https://go-review.googlesource.com/c/138878
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-16 20:20:09 +00:00
Alan Donovan
bf9c22dffd go/analysis/passes/httpresponse: split out from vet
Change-Id: Ica54852964837182d1848d4d96d43309ad0a6d84
Reviewed-on: https://go-review.googlesource.com/c/142477
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-16 19:47:10 +00:00
Alan Donovan
3a0c4deef1 go/analysis/passes/printf: changes for analysis API
Guide to changes:

- The -printfuncs flag is renamed -printf.funcs.
  It no longer supports "pkg.T.f" form, requiring instead
  "(dir/pkg.T).f" or "(*dir/pkg.T).f".
  The legacy ":%d" suffix is no longer supported.

- (*testing.T).Errorf and friends are removed from the isPrint map
  because they are discovered by induction while analyzing package
  "testing".

- localPrintfLike map operations are replaced by the Fact mechanism.

- The go/types representation is used instead of strings/ast.Nodes in
  various places. For example:

       pkgpath, name string -> *types.Func  (to identify a function)
    format, args *ast.Field -> *types.Var   (to identify format/args params)

  This was required to fix a latent bug in maybePrintfWrapper's
  handling of format string parameters` declared using "factored"
  syntax, such as: func f(foo, format string, args...interface{}).
  See L253 of the original testdata file for a testcase that ensured
  the buggy (?) behavior.

- func printfLike is removed as it was deadcode.

- isFormatter is rewritten to avoid a global variable.

- "if verbose { warn }" is replaced by "if false { report }" for now.

- recursive stringer is rewritten more simply in term of go/types.

Change-Id: Ia6ee827117b611c686e38207916a21fe1fc296e2
Reviewed-on: https://go-review.googlesource.com/c/142239
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-16 19:44:49 +00:00
Heschi Kreinick
bf693efdb3 imports: make tests use a helper, read from disk more
Replace the repeated Process/err check/output block with a test helper
eliminating a lot of copy/pasting. Change many tests to get their input
from disk rather than the argument to Process; this is mostly me being
selfish: go/packages doesn't support creating new packages with overlays
and that breaks a lot of these tests.

Change-Id: Ib1b7908c3d86d17323a94f1ee4ce074e264327b4
Reviewed-on: https://go-review.googlesource.com/c/141680
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-16 19:29:16 +00:00
Yury Smolsky
321fe744f3 playground.js: make output of "Run" clearer
This CL changes the last line displayed after the program was run
to display more details on what happened.

If the program cannot be built,
the last message is "Go build failed".

If the program has tests,
the last message is "All tests passed" in case of success.
Otherwise it is "N tests failed".

If the program has exited with non-zero code,
the exit message is postfixed with the code.

This CL adds output for timed out programs.

This CL is prerequisite for the backend change in CL 141478.
Dockerfile in playground repo has to be updated to include this CL.

Updates golang/go#10590
Updates golang/go#25454

Change-Id: Ie0a51b0729c574d2508a4a1b89f629def1d79fd6
Reviewed-on: https://go-review.googlesource.com/c/141477
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-10-16 19:24:31 +00:00
Agniva De Sarker
4fd3307906 godoc: fix inline playground width for mobile devices
The inline playground had a fixed width due to which it gets partially
hidden on mobile devices. Hence, expanding the div to fit the entire
screen properly inside the media query for mobile resolutions.

Also, since the playground appears on top of the button, there is
no way to hide it except to reload the page. So, added a click handler
on the page to hide the playground if it is open.

Fixes golang/go#21636

Change-Id: Id15caec25e870e9ff3be7736e2bb1084591d1016
Reviewed-on: https://go-review.googlesource.com/c/129435
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-16 15:29:12 +00:00
Ian Cottrell
3bba456143 go/packages: don't use os.LookupEnv
Get the value of GOARCH from the config instead.
It should have been set to the same as the one from the environment by
default, but may have been overidden by the caller.

Change-Id: If9a6c0ae998c1c72ad2a68fe83c8bb9f5614a189
Reviewed-on: https://go-review.googlesource.com/c/142361
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-16 15:13:54 +00:00
Michael Matloob
5d4988d199 go/packages: fix TestRejectInvalidQueries test case
We agreed on a different set of invalid queries than what the test
tests. The change got lost in a merge. Fix it.

Change-Id: I812e561d924f5dbd0c29e3a6ec5fb53022d09487
Reviewed-on: https://go-review.googlesource.com/c/142359
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-10-15 22:13:41 +00:00
Alan Donovan
91ec7db2f8 go/analysis/passes/shadow: split out of vet
This is just a rename for ease of review.
The logic change will follow.

Change-Id: I8856b22f2157d63c6983c0f00a12c87e5d5dd1a4
Reviewed-on: https://go-review.googlesource.com/c/142357
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2018-10-15 21:45:49 +00:00
Alan Donovan
d777022dd8 go/analysis/passes/structtag: split out from vet
Change-Id: Ib3c4c783e4bca2bf2b3c76bea8f19959b7e39539
Reviewed-on: https://go-review.googlesource.com/c/142097
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-15 21:04:11 +00:00
Alan Donovan
8919434dde go/analysis/passes/copylock: add workaround for go1.10
CL 121876 made sync.noCopy implement sync.Locker and
added this as an assumption to vet.  But now that copylock
is no longer in the standard library it cannot
assume that it is analyzing a recent standard library
in which noCopy has an Unlock method.

Change-Id: I5a30b3711ae6cc0855eb246fdd93b1906779bdde
Reviewed-on: https://go-review.googlesource.com/c/141683
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-15 20:10:34 +00:00
Alan Donovan
cdd5f6199c go/analysis/passes/printf: add types.go too
This file is nominally part of the core vet tool but in reality it is
only used by the printf checker.

This is just a rename; the actual change will come in a follow-up.

Change-Id: I5497d6888228e6781cf0d3ae62b7c6b5b723e151
Reviewed-on: https://go-review.googlesource.com/c/142240
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2018-10-15 19:52:40 +00:00
Alan Donovan
104357fe96 go/analysis/passes/printf: move printf to correct subdirectory
Change-Id: I9c510fe042461707a47d8ba4fb4f70c33efbc8cc
Reviewed-on: https://go-review.googlesource.com/c/142238
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2018-10-15 19:19:59 +00:00
Alan Donovan
25a9b7c729 go/analysis/passes/printf: create printf pass
This is a straight rename to simplify review of the actual change in a
follow-up CL. (This is a workaround for git diff's weak support for
renames.)

Change-Id: If63336d4f782e12066fce83a848465371013cdde
Reviewed-on: https://go-review.googlesource.com/c/142237
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2018-10-15 19:09:06 +00:00
Alan Donovan
aa46a01996 go/ssa/ssautil: add AllPackages method
In go1.10, go/packages falls back to loading all packages
from source but not typechecking function bodies for imports.
The ssautil.Packages function would nonetheless provide
the partially-typed ASTs to the SSA builder, which would crash.
Now Packages only passes syntax trees to the SSA builder for
the initial packages, which are the only ones guaranteed to be
fully typed.

It is impossible to discern whether the caller of Packages intends to
build SSA code for dependencies, as in some clients such as
cmd/callgraph, so we add a new function, AllPackages, that expresses
this intent.

Fixes golang/go#28106

Change-Id: I6a88b7c7545e9de90b61f5bee0e6de3d2e21b548
Reviewed-on: https://go-review.googlesource.com/c/141686
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-15 18:41:29 +00:00
Michael Matloob
4b6ee5fb87 go/packages: remove scary warning on documentation
Add a guarantee for breaking changes.

Change-Id: I7c176eb0c3a309ad187e3a33a645996e397d09be
Reviewed-on: https://go-review.googlesource.com/c/141684
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-10-15 17:50:52 +00:00