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

2751 Commits

Author SHA1 Message Date
Alan Donovan
792c3e655c go/types/objectpath: fix tests for pre-go1.11
The behavior of go/types.ObjectString (or perhaps the underlying
object) changed at some point.

Change-Id: I77f1d13c180e1f78ddc08e80e5d38aa01f425111
Reviewed-on: https://go-review.googlesource.com/138777
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-10-01 16:20:35 +00:00
Alan Donovan
b3c0be4c97 go/ast/inspector: faster (amortized) AST traversals
This new package provides helper functions for traversal over the
syntax trees of a package, including node filtering by type, and
materialization of the traversal stack.

During construction, the inspector does a complete traversal and
builds a list of push/pop events and their node type. Subsequent
method calls that request a traversal scan this list, rather than walk
the AST, and perform type filtering using efficient bit sets.

Experiments suggest the inspector's traversals are about 2.5x faster
than ast.Inspect, but it may take around 5 traversals for this benefit
to amortize the inspector's construction cost.

This design is well-suited to the ongoing reworking of cmd/vet (see
docs.google.com/document/d/1-azPLXaLgTCKeKDNg0HVMq2ovMlD-e7n1ZHzZVzOlJk),
which historically made a single pass over the ASTs but is being
replaced by a design that requires a separate pass for each analysis.

Change-Id: I9a67aed6a3bf948076641d96447860d97ede67b4
Reviewed-on: https://go-review.googlesource.com/135655
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-09-28 18:13:43 +00:00
Michael Matloob
16720d5f2d go/packages: allow absolute paths when using the fallback
Another change to bring the go1.10 fallback's functionality in line with
the go1.11 go list implementation. The fallback now uses go env to
determine GOPATH and GOROOT and searches them to see if any match an
absolute path, and if so trims the GOPATH/GOROOT entry off  the start
of the path.

Fixes golang/go#27734

Change-Id: Ibd2313fc4301d42fd8c0cd98f1f3e7a313d65eb7
Reviewed-on: https://go-review.googlesource.com/137096
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-09-28 17:53:27 +00:00
Alan Donovan
51aacb1402 go/analysis: add command-line help
The format of Analyzer.Doc is now specified as a short title followed
by a longer description. This allows us to build a nice
self-documenting command-line interface. Much of the documentation in
vet's doc.go and file-level comments can now be displayed to the user.

Change-Id: I462343e97ac9b743284aaa3e06e7a81d11e9593f
Reviewed-on: https://go-review.googlesource.com/138396
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-09-28 16:51:45 +00:00
Alan Donovan
7b71b077e1 go/analysis/analysistest: refuse to analyze zero packages
It's easy to forget to pass the last argument,
in which case the test would silently pass.

Change-Id: I95249e1fe8bee75cfaa535fcf723d04f102214fc
Reviewed-on: https://go-review.googlesource.com/138395
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-09-28 16:40:45 +00:00
Agniva De Sarker
ae8529dc16 godoc/vfs/zipfs: join paths to get correct RootType
The logic was incorrectly written from vfs/os.go. zipfs filesystem
passes actual paths during dirTree building. So we need to join the paths
to determine whether they are under GOROOT or GOPATH.

Updates golang/go#27205

Change-Id: Ic4330fce02c6ebfc44ae21122e2412c33f0cd45a
Reviewed-on: https://go-review.googlesource.com/138435
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-09-28 16:24:37 +00:00
Alan Donovan
73ed285d4c go/types/objectpath: a stable naming scheme for types.Object
Type-checker objects are canonical, so they are usually identified by
their address in memory (a pointer), but a pointer has meaning only
within one address space. By contrast, objectpath names allow the
identity of a logical object to be sent from one program to another,
establishing a correspondence between types.Object variables that are
distinct but logically equivalent.

This package was developed for Google's internal fork of guru.
It is needed for lemma support in the analysis API; see
docs.google.com/document/d/1-azPLXaLgTCKeKDNg0HVMq2ovMlD-e7n1ZHzZVzOlJk

Change-Id: I9899ce14d57909858a68f84e90d58a039f2bb7a0
Reviewed-on: https://go-review.googlesource.com/135675
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-09-28 15:15:07 +00:00
Bryan C. Mills
84988e2dba go/packages: do not error out for patterns that match no packages
The documentation for Load says:
“Load returns an error if any of the patterns was invalid as defined
by the underlying build system. It may return an empty list of
packages without an error, for instance for an empty expansion of a
valid wildcard. Errors associated with a particular package are
recorded in the corresponding Package's Errors list, and do not cause
Load to return an error.”

Therefore, it should not be an error for a pattern to match no
packages. If the pattern is a literal package path that does not
exist, we should prefer to return a *Package for it with an error in
the Errors field.

Change-Id: Iaecfb920097e3b520e763bd52c0e326d2e7a4861
Reviewed-on: https://go-review.googlesource.com/137075
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-09-28 12:33:17 +00:00
Chris Broadfoot
e9ca907325 cmd/godoc: simplify dev and prod environment for App Engine
Remove all of the code generation and the concept of "APPDIR" - just
generate godoc.zip and index files in the app directory.

Simplify generation of the zip - use a symlink so that every file in
godoc.zip is under the "goroot" directory, regardless of the
environment. Previously, the prefix would be dependent on the location
of the user's GOROOT.

Running the setup script is now optional - it's now possible to run
dev_appserver.py on a regular checkout of cmd/godoc without godoc.zip
and search index files. Use environment variables to switch whether the
zip file is used vs reading GOROOT from the filesystem.

Change-Id: I1ce95c891717fe2da975f979778fd775b23f18c8
Reviewed-on: https://go-review.googlesource.com/46725
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-09-28 11:54:07 +00:00
Alan Donovan
1be7b45b4c go/analysis/passes/vet: fork cmd/vet@31d19c0
This change creates a fork of vet from the standard distribution.

It was created by this script:

 $ mkdir go/analysis/passes/vet/
 $ cd go/analysis/passes/vet/
 $ (cd $GOROOT/src/cmd/vet >/dev/null && git co 31d19c0 && tar cf - .) | tar xf -
 $ rm -fr all              # We'll deal with cmd/vet/all later.
 $ rm -fr internal/cfg     # Published as golang.org/x/tools/go/cfg.
 $ sed -i -e '1s?^?// +build ignore\n\n?' *.go

All the Go files have been tagged "ignore" for now.
A series of follow-up changes will convert each vet check
into an instance of the new go/analysis API's Analyzer.

At some point soon, cmd/vet in the standard distribution will use a
vendored copy of this code. Until then we will periodically integrate
any changes made to cmd/vet to this fork. The current version of
cmd/vet will be recorded in the REVISION file.

Change-Id: I0c63eeb17cc612b3f013679595dcbc71a90950f7
Reviewed-on: https://go-review.googlesource.com/138137
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-09-27 19:02:35 +00:00
Alan Donovan
b41e4b469b go/analysis: add Pass.OtherFiles field
This field lists the names of non-Go files that are part of the
package under analysis.

Change-Id: Ic967dc18b98e018c691442f7378cb29db30a1454
Reviewed-on: https://go-review.googlesource.com/138136
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-09-27 17:26:44 +00:00
Rebecca Stambler
d457fc8054 cmd/golsp: support formatting in golsp
This commit adds support for some basic commands necessary for
integration with VSCode. It also adds support for the
"textDocument/format" method.

Change-Id: I8fd0e33ca544ab65d3233efe2fef9716446ad4ff
Reviewed-on: https://go-review.googlesource.com/138135
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-09-27 17:02:42 +00:00
Alan Donovan
308f0c7c09 go/analysis: revert UsesFacts to FactTypes
Forcing clients to register their Fact types with gob made for an
unfriendly API. Now the driver is again responsible for doing it.

The FactTypes field is now a slice of Fact values (not reflect.Types)
used only for their dynamic type, which is slightly more convenient.

Change-Id: I01219edb24bd2371ba642bb56508aa80c19a9b61
Reviewed-on: https://go-review.googlesource.com/137836
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-09-27 16:40:32 +00:00
Ian Cottrell
ef04bbebd8 cmd/golsp: An empty shell of an lsp server for the go language
Change-Id: I51ef556048c2d10537ad90fa5284939e09bc31fd
Reviewed-on: https://go-review.googlesource.com/137097
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-09-27 15:24:00 +00:00
Robert Griesemer
9e2f8b2a0a go/internal/gccgoimporter: remove special case for Go1.9
The supported x/tools versions are now all at least Go1.9.

Change-Id: I9476329f2be8f3c560efb280f06d65669a3e9f85
Reviewed-on: https://go-review.googlesource.com/137996
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-09-27 15:01:54 +00:00
Robert Griesemer
b14f328a62 go/internal/gccgoimporter: port recent changes from stdlib version
This CL brings over the following changes from the std lib:

	https://golang.org/cl/137857
	https://golang.org/cl/137935
	https://golang.org/cl/137975

There are no further code changes except that the importer test
cases are split between importer_test.go and importer19_test.go
to support multiple Go versions.

Updates golang/go#27856.

Change-Id: I625def738c22c24c6659af37c3871038fdd8b981
Reviewed-on: https://go-review.googlesource.com/137995
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-09-27 04:48:12 +00:00
Alan Donovan
ef4a2a23bb go/analysis/analysistest: fix tests on MS Windows
CL 137735 only fixed Darwin, and was submitted prematurely.

Change-Id: Idf9706ab2dc6ef716471cd6a2089bb0be63a54a2
Reviewed-on: https://go-review.googlesource.com/137835
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-09-26 20:30:08 +00:00
Alan Donovan
34cd4017e8 go/analysis/analysistest/analysistest: fix test on non-Linux
The test's pathname sanitization heuristically assumed that $TMPDIR
contained /tmp, which is not the case on Darwin or Windows. Now we
pass it the precise directory prefix to strip off.

Fixes golang/go#27877

Change-Id: I85167d721ebb9c4f6d74016a00025fd726939e47
Reviewed-on: https://go-review.googlesource.com/137735
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-09-26 20:13:27 +00:00
Alan Donovan
c756801b01 go/analysis/internal/checker: fix go1.10 build
...by removing references to trace API for now.

Change-Id: Ide6bbbfd98e15a3773b4a10232bcbf2dc2153341
Reviewed-on: https://go-review.googlesource.com/137615
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-09-26 13:06:41 +00:00
Jamie Wilkinson
9eb9690e39 cmd/goyacc: put //line annotations on the first column.
This appears to have broken since go1.11, and "go doc compile" and
https://golang.org/issue/24183 documents this new convention (point
2)

Change-Id: I6a4bc0fc51a18c17ac9a72a67d9a8eb4c879e0f9
Reviewed-on: https://go-review.googlesource.com/137515
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-09-26 03:27:08 +00:00
Alan Donovan
d5fdb01c2f go/analysis/internal/checker: analysis driver based on go/packages
Package checker is a driver for the analysis API.
It is an internal package, but is exposed by three different APIs:
analysistest, singlechecker, and multichecker.

Checker uses go/packages to load the specified packages (plus their
dependencies, if any analysis uses facts) from source code.

It constructs a graph of actions (analysis passes), whose dependency
edges may be "horizontal", when one analyzer depends on the output of
another applied to the same package, or "vertical", when an an
analyzer consumes facts produced by the same analyzer applied to a
dependency package.
The graph is executed in parallel, unless -debug=p.

Facts are passed from one pass to another in memory.
If -debug=s, facts are serialized, to exercise that logic.

Findings are printed at the end.
The -json flag selects JSON output.

Use -debug=t to print timing information.
Always use -debug=tp, for sequential mode, when timing.

Also:
- analysistest:  a wrapper for testing checkers
- multichecker:  a wrapper for writing multi-checker tools
                 Analysis flags are prefixed by name: -findcall.name=foo.
- cmd/analyze:   a command-line tool based on multichecker
- singlechecker: a wrapper for writing single-checker tools
                 Analysis flags are unprefixed: -name=foo.
- passes/findcall/cmd/findcall: a standalone tool for the findcall analysis
- tests for findcall
- tests for pkgfact

Change-Id: Icfd4a49cee17e7de1ddb6ec15a62dc667fb2db04
Reviewed-on: https://go-review.googlesource.com/135679
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-09-26 01:25:07 +00:00
Alan Donovan
942d58378d go/cfg: a syntactic control-flow graph (CFG)
This package defines a control-flow graph of Go statements and
expressions. It was originally built as part of cmd/vet (where
it was in turn derived from x/tools/go/ssa) and is being
published to make it available to other analyses.

Change-Id: Ib6077c5a856bb74d6a8411e9c3f9e2f79beb5658
Reviewed-on: https://go-review.googlesource.com/135636
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-09-26 00:57:46 +00:00
Alan Donovan
31d48d9a8c go/analysis: more API renamings:
Info -> TypesInfo
              Syntax -> Files
          Diagnostic -> Finding

Also, diagnostics are now reported by calling Pass.Report (or Reportf).

Change-Id: Id5e0745fca914699a6a64be3554049ffc02e822b
Reviewed-on: https://go-review.googlesource.com/137395
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-09-25 20:33:08 +00:00
Michael Matloob
0b24b358f4 go/packages: add missing test variants to fallback loader
For all packages p, q where there's an dependency path of
p.test -> ... -> q -> ... -> p, Go creates test variants
q [p.test] of each q and replaces the dependency on q with
a dependency on q [p.test], and replaces p with the expanded
test variant p[p.test]. Fix the fallback logic to add
these missing test variants. (Before this change, it was
only producing the variant of p: p [p.test].)

Fixes golang/go#27670

Change-Id: Ic56ba35fadcdf8c5928ec76f5a7b0ebe650c9f02
Reviewed-on: https://go-review.googlesource.com/136176
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-09-25 16:56:39 +00:00
Alan Donovan
e2857128af go/analysis: several API renamings
Analysis -> Analyzer
                 Unit     -> Pass
                 Output   -> Result
                 Inputs   -> ResultOf
                 Lemma    -> Fact
 Set{Object,Package}Lemma -> Export{Object,Package}Fact
    {Object,Package}Lemma -> Import{Object,Package}Fact
               LemmaTypes -> UsesFacts bool
                 plugins/ -> passes/

Notes:
- Unit.Output is no longer a field; it's the result of calling Analyzer.Run.
- Because analyzers no longer declare their LemmaTypes, they, not the
  driver, are now responsible for registering Fact types with Gob.

A follow-up change will additionally rename:

                  Finding -> Report
              Pass.Syntax -> Pass.Files
                Pass.Info -> Pass.TypesInfo

Change-Id: Iccbdadbea5a0aafe732e23a344dd57fd93681931
Reviewed-on: https://go-review.googlesource.com/137095
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-09-25 16:28:27 +00:00
Bryan C. Mills
dca76387a0 go/ssa/interp: skip failing test
This test introduces noise when using 'go test all' or 'go test ./...'
to test go/packages and the tools that depend on it.

Since it has been broken for around a month, skip it indefinitely.

Updates golang/go#27292

Change-Id: I796292310332712e14bc8a0b73e36a8ed6f8a73f
Reviewed-on: https://go-review.googlesource.com/137315
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-09-25 15:50:07 +00:00
Ian Cottrell
ff3f684ce0 internal/lsp: the core lsp protocol
This is not intended to be a user friendly package, just the rawest correct
implemenation of the protocol as a building block

Change-Id: Ib672b7f1e2fd8284be422dc7964f1876e94c9578
Reviewed-on: https://go-review.googlesource.com/136676
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2018-09-25 15:17:08 +00:00
Ian Cottrell
e93be7f42f internal/jsonrpc2: a basic json rpc library to build an lsp on top of
Change-Id: I6aa47fffcb29842e3194231e4ad4b6be4386d329
Reviewed-on: https://go-review.googlesource.com/136675
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2018-09-24 17:56:01 +00:00
Michael Matloob
90fa682c2a go/packages: generate test main files from the golist fallback
Part of the testmain generation logic (sans coverage) has been taken
from go build and put into golist_fallback_testmain.go.
golist_fallback invokes this logic and builds up the package metadata
for the testmain.
The tests checking for testmain are now no longer skipped from
packages_test.go.

Change-Id: I487a947f087f3ad4161ea6c2bed06ebb2f833422
Reviewed-on: https://go-review.googlesource.com/134119
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-09-17 22:19:12 +00:00
Alan Donovan
9f3b32b5c4 go/analysis: a new API for analysis tools
This CL contains just the API, the validate function,
and two example analyses, findcall and pkglemma.

Change-Id: Ia1f2652647050b1e0e15dad8b9ae10cf1a5fbdbc
Synopsis: go-review.googlesource.com/c/tools/+/134935
Design:   docs.google.com/document/d/1-azPLXaLgTCKeKDNg0HVMq2ovMlD-e7n1ZHzZVzOlJk
Reviewed-on: https://go-review.googlesource.com/135635
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-09-17 22:09:49 +00:00
Alan Donovan
02eab57fcf go/types/typeutil: add StaticCallee helper function
StaticCallee reports the destination of a CallExpr, if it is a static
call to a Go function or method.

StaticCallee is not a complicated function, but I wrote it four times
during the course of prototyping the analysis API in
go-review.googlesource.com/c/tools/+/134935.

Change-Id: Icd26fc1e5f6ed9edebd4d0a00fdf18aa0acb074c
Reviewed-on: https://go-review.googlesource.com/135676
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-09-17 22:04:51 +00:00
Alan Donovan
677d2ff680 go/ssa: use correct type for variadic parameter in wrapper methods
For some reason, the type of the last Param in a wrapper function
for a variadic method (T) f(...U) had type [][]U instead of []U.
(Possibly a workaround for a long-since fixed bug in go/types?)

Added a sanity check to ensure that the common suffix of
fn.Params and fn.Signature.Params match in type.

Fixes golang/go#27453

Change-Id: I9506f4f67a7ff3a283e9ec0142f638aad00287a9
Reviewed-on: https://go-review.googlesource.com/134515
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-09-11 13:30:44 +00:00
Koichi Shiraishi
18207bb12d go/packages: remove unnecessary newline on import section
Change-Id: I5d0019b76335460b35d4253f5c534810cc6bda77
Reviewed-on: https://go-review.googlesource.com/134335
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-09-10 18:00:08 +00:00
Dmitri Shuralyov
becf93d7cf imports: update zstdlib to Go 1.11
Go 1.11 has been released; it's time to update zstdlib so
imports knows about API additions that went into Go 1.11.

Unfortunately, this does not include the syscall/js package
that was added in Go 1.11 for WebAssembly. This is because
it's not included in the GOROOT/api/go1.11.txt file. Getting
it into imports can/will be done in a future CL (after some
discussion of the best way to do it).

Previously:

-	https://golang.org/cl/93195 (Go 1.10)
-	https://golang.org/cl/49150 (Go 1.9)

Updates golang/go#27590.

Change-Id: I229d7c0a658b0d8090b58cfe844c95b4cb0b2212
Reviewed-on: https://go-review.googlesource.com/134176
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-09-10 04:49:24 +00:00
Kevin Burke
af9b995e7e imports: rerun "go generate" with new gofmt
This reformats the table using the new gofmt rules in Go 1.11. No
changes apart from the whitespace change.

Change-Id: I74a1d9c14ec7a4f691e78cc7ffa443da68fb8681
Reviewed-on: https://go-review.googlesource.com/132395
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-09-10 02:05:53 +00:00
Michael Matloob
0aa4b8830f go/packages: remove the Config.Error hook
Errors relating to a particular package (as opposed to the Load
operation as a whole) are now only recorded in the Errors
field of the corresponding Package.
Clients are responsible for printing or otherwise handling errors.
This is a breaking API change.

The PrintErrors function prints all accumulated errors,
dependencies first, and is provided for convenience.

PrintErrors is based on Visit, another helper function, which
visits each Package in an import graph.

Also:
- add an Example documenting typical use.
- update clients to handle errors explicitly.

Depends on https://go-review.googlesource.com/c/tools/+/130576

Change-Id: I39407ab7f46dae2f0dd0fdde21080e172e1258aa
Reviewed-on: https://go-review.googlesource.com/131015
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-09-04 20:52:37 +00:00
Michael Matloob
18b2bbde9d go/packages: fix incorrect x_test graph in fallback
This change fixes a bug that occured in the golist fallback logic when
an x_test package imported its own package under test. For a package
"a", if "a_test" imported "a", we'd populate "a_test"'s import map
with an entry "a [a.test]" pointing to the test variant of the package
with id "a [a.test]". This change fixes the key to be "a", the correct
import path of the package, not "a [a.test], which is the ID".

Change-Id: If798f2675b01aa537c6ccc129dc35d042d967337
Reviewed-on: https://go-review.googlesource.com/133356
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-09-04 20:42:50 +00:00
Michael Matloob
f1c1faf65a go/packages: coerce all errors to a single type
Rather than document the range of possible error types, requiring
clumsy client code to extract position information, we now expose a
single concrete type for all errors. Position information (in
standardized string form) is technically optional, but we should
strive for 100%, fixing gaps as they arise.

This change enables us to unify the Package and JSON structs in a
follow-up.

Question: should we eliminate the Config.Error hook and be silent by default?
Pro:
+ most clients suppress it.
Con:
- clients that want to print errors (e.g. vet-like tools) would have
  to traverse the entire import graph to find them.
- silence is not the most fail-safe behavior.

Change-Id: Ie92b9fb7641ceda429f00928474b650d1dfadedd
Reviewed-on: https://go-review.googlesource.com/130576
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-09-04 20:04:35 +00:00
Todd Neal
7ca1327549 go/packages: fix docs
Change-Id: Ife879995fd1a8f23821efefe6970a0e907f2fb12
Reviewed-on: https://go-review.googlesource.com/132600
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Kevin Burke <kev@inburke.com>
2018-08-31 21:12:45 +00:00
Kevin Burke
4bc20fc791 godoc: fix indenting on Firefox
See comment in the patch for an explanation, Firefox (specifically
with the Menlo font) does not like tabs beginning in column 9, so we
start it in column 10.

Updates webcompat/web-bugs#17530
Fixes golang/go#26316
Fixes golang/go#23500

Change-Id: I4c96118b8c3b13ee1fd21ce85bd7c681e99a4b4f
Reviewed-on: https://go-review.googlesource.com/131716
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-08-30 21:44:40 +00:00
Andrew Bonventre
6cd1fcedba cmd/godoc: remove workaround for 1.8 behavior
1.8 is no longer supported. Remove code that placates it.
Also removes a superfluous newline in appinit.go.

Change-Id: I9c89b5bddf4c001d0854404114fb354209ad6024
Reviewed-on: https://go-review.googlesource.com/131715
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-28 01:58:42 +00:00
Brad Fitzpatrick
4426aff4d0 go/ssa/interp: disable regularly broken tests in short mode
Updates golang/go#27292

Change-Id: I845afc64ca9ed2065c3b5645b7ce6def290d7a6d
Reviewed-on: https://go-review.googlesource.com/131717
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-28 01:46:48 +00:00
Brad Fitzpatrick
f6ba574295 godoc/dl: update Mac & Windows minimum versions
Updates golang/go#27213

Change-Id: I25813e9aafcdb39d4f93e27b98d8672c770234a6
Reviewed-on: https://go-review.googlesource.com/131402
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-08-26 00:09:51 +00:00
Agniva De Sarker
b776bcbf45 godoc/vfs: improve comment on GOROOT
GOROOT is not a function, so use "is" instead of "returns".
This was originally raised during review of golang.org/cl/131315.

Also add a missing period.

Change-Id: Ie28d38529889702ae5035d0f48d8122b6bee6819
Reviewed-on: https://go-review.googlesource.com/131316
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2018-08-26 00:05:47 +00:00
Agniva De Sarker
6c1c5e93cd godoc/vfs: reorder comment paras to display the correct one
This is a fixup for golang.org/cl/130796.

Change-Id: If151325738b59ab61a7b456a140d3bc8dff57b9c
Reviewed-on: https://go-review.googlesource.com/131315
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2018-08-24 17:52:16 +00:00
Jay Conrod
ff6c8c104a go/packages: initialize config.Env with os.Environ when unset
This makes Load use the value of GOPACKAGESDRIVER in the current
process's environment if the loader's environment wasn't explicitly
set.

Note that if GOPACKAGESDRIVER is not set, we'll still search PATH in
the current process, regardless of whether PATH is set in the loader's
environment. This has not changed.

Change-Id: I3081a6cb0876a21ccd4d87b4b8d082aa47911b75
Reviewed-on: https://go-review.googlesource.com/131016
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-23 20:10:42 +00:00
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