Russ Cox [Tue, 7 Aug 2018 19:50:24 +0000 (15:50 -0400)]
cmd/go: fix module loader and test-only dependencies
go list all was not behaving as documented - it did not pick up
test dependencies except when running in "go test" and "go vet".
It should pick them up always.
Also the module loader was ignoring tests when using "go list -test",
which led to load failures.
Fixing all required adjustments to mod_patterns test.
Removed error-prone exact listings.
Fixes #26279.
Fixes #26906.
Change-Id: I9c5acaf2275be20fd2349859589502190d3e7a78
Reviewed-on: https://go-review.googlesource.com/128358 Reviewed-by: Bryan C. Mills <bcmills@google.com>
Suzy Mueller [Thu, 9 Aug 2018 17:05:54 +0000 (13:05 -0400)]
cmd/go: make 'go list -test' report the correct import path
When a test variant of a package is created, the two versions cannot
share memory for the fields that contain information about their
imports, as these will be different between the two packagse.
Both the Internal.Imports and the Imports fields must be able to be
updated in the test variant without affecting the values of the
original.
David Chase [Wed, 18 Jul 2018 20:18:28 +0000 (16:18 -0400)]
cmd/compile: update delve's reference data for ssa/debug_test
Recent versions of Delve pay attention to the debugging changes
for 1.11, which causes different (better!) debugging behavior.
Update the reference data to reflect this.
Change-Id: I2efa165aa71769ace9f7885b4ce3420cd9b2d3a3
Reviewed-on: https://go-review.googlesource.com/128697
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Bryan C. Mills [Thu, 9 Aug 2018 21:38:32 +0000 (17:38 -0400)]
cmd/go: skip TestScript/mod_patterns on nocgo builders
Updates #26906.
Change-Id: I61b08180aefe9cfc109a1009ca251ee6970eb2df
Reviewed-on: https://go-review.googlesource.com/128879
Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Bryan C. Mills [Mon, 6 Aug 2018 20:59:31 +0000 (16:59 -0400)]
cmd/go/internal: factor out modload.QueryPackage and use in in modget
modload.Import contains a loop that looks for the module containing a package.
Because we overload Import to locate both packages and modules, that loop
contains a bunch of special-cases for modules with empty roots.
In this change, we factor out the loop into a new function (QueryPackage) and
use that directly in modget.getQuery. That restores the invariant that
the paths passed to modload.Import must be importable packages, and fixes 'go
get' lookups for packages that have moved between a module and submodules with
the same path prefix.
Bryan C. Mills [Mon, 6 Aug 2018 21:25:10 +0000 (17:25 -0400)]
cmd/go/internal/modload: report errors explicitly from Lookup
Previously, we reported errors directly in (*loader).load via base.Errorf.
Unfortunately, (*loader).load can be called from contexts in which such errors
should not be considered fatal, such as by load.PackagesAndErrors.
Instead, we save the errors in pkg.err and modify Lookup to return that error.
This change is a bit awkward: we end up suppressing a "no Go files" error for
packages at the root of newly-imported modules, even if they really do contain
source files. I believe that that's due to a special-case lookup for modules in
the build list, which allows us to "validate" imports for modules in the build
list even though we haven't actually downloaded their sources (or verified that
they actually contain the requested package). The fix for that issue is in the
change that follows this one.
Rebecca Stambler [Thu, 9 Aug 2018 16:34:19 +0000 (12:34 -0400)]
go/types: fix errors in recording type information
In my previous change, I didn't use the correct functions for continuing
to record type informations after errors. Change to using the correct
functions, and add a comment to clarify in expr.go.
Updates #22467
Change-Id: I66ebb636ceb2b994db652343430f0551db0050c3
Reviewed-on: https://go-review.googlesource.com/128835
Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Bryan C. Mills [Mon, 6 Aug 2018 22:06:06 +0000 (18:06 -0400)]
cmd/go: test that 'go get pkg@version' installs pkg
This test passes, but it encodes several behaviors that I think are bugs.
I suggest that we check it in as-is, and we can update it as the bugs are fixed.
Mostyn Bramley-Moore [Wed, 8 Aug 2018 21:34:43 +0000 (21:34 +0000)]
doc.Example should not worry about unresolved blank identifiers
https://golang.org/pkg/bufio/#example_Scanner_custom is not directly
runnable in the playground via godoc, but if I copy+paste the code into
https://play.golang.org/ then it runs just fine.
This seems to be due to the blank identifier being considered unresolved
in the following line in the example:
_, err = strconv.ParseInt(string(token), 10, 32)
But that's the whole point of blank identifiers- they're not supposed
to be resolved. So let's skip adding the blank identifier to
doc.playExample's unresolved map.
Leigh McCulloch [Sat, 4 Aug 2018 06:40:45 +0000 (06:40 +0000)]
doc/contribute: add examples for finding issues on the issue tracker
For contributors looking for new issues to contribute to it can be
difficult to find issues that need a fix and don't already have a fix
being considered. There are several labels that help guide the way
already, like `NeedsFix`, `HelpWanted`. But many issues with this label
will already have a CL. For new contributors this can be especially
difficult.
Fixes #26494
Change-Id: Ifd38ea65e362b4c580207a06f959646e49ac594f
GitHub-Last-Rev: 6d2b54447b2ee754a6d025f5de3ebd8326e035eb
GitHub-Pull-Request: golang/go#26516
Reviewed-on: https://go-review.googlesource.com/125355 Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Robert Griesemer [Wed, 8 Aug 2018 00:53:59 +0000 (17:53 -0700)]
go/types: if base type for an alias is known, use it when needed
Because methods are type-checked before the receiver base type
is "complete" (i.e., they are checked as part of the receiver
base type), situations occur where aliases of those base types
are used (in those methods) but the alias types are not known
yet (even though their base types are known).
This fix is a temporary work-around that looks syntactically
for the base types of alias types and uses those base types
when we refer to an "incomplete" alias type. The work-around
is completely localized and guarded with a flag so it can be
disabled at short notice.
The correct fix (slated for 1.12) is to decouple type-checking
of methods from their receiver base types. See issue #26854.
Fixes #26390.
Change-Id: I66cc9d834b220c254ac00e671a137cf8a3da59c1
Reviewed-on: https://go-review.googlesource.com/128435 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
Daniel Martí [Wed, 8 Aug 2018 12:53:10 +0000 (13:53 +0100)]
net: reduce TestSplice/big's memory usage
The old code used splice on a 2GB []byte when not in short mode, meaning
that running 'go test net' when one had 4GB or less free memory would
easily result in "out of memory" runtime panics.
Instead, use a much smaller size that is still big enough to not fit
into a single splice(2) syscall. The new size is just 5MB, so the test
uses a fraction of the memory it used to, and there's no longer a need
for a different size on short mode.
This also speeds up the test, which goes from ~1.23s to ~0.01s on my
laptop.
Fixes #26867.
Change-Id: Iae1daa5c0995b549f41992f44339be32ca1ee5e4
Reviewed-on: https://go-review.googlesource.com/128535
Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Andrei Tudor Călin <mail@acln.ro> Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Gn Shivakumar [Sun, 29 Jul 2018 17:56:52 +0000 (23:26 +0530)]
cmd/go: 3 cmd/go tests (>8s) made as non-short scripts
* TestAtomicCoverpkgAll -> Script/cover_atomic_pkgall.txt and make it
* non-short
* TestCoverpkgAllRuntime -> Script/cover_pkgall_runtime.txt and make it
* non-short
* TestCpuprofileTwice -> Script/cpu_profile_twice.txt and make it
* non-short
* TestGoTestMainTwice -> make it non-short
Updates #26472
Change-Id: I24f3d4c2a8b6e317adb369a1b1426e693f9571ed
Reviewed-on: https://go-review.googlesource.com/126636 Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Bryan C. Mills [Wed, 1 Aug 2018 17:22:02 +0000 (13:22 -0400)]
cmd/go: make 'go get <module>@none' idempotent
Before this change, 'go get <module>@none' for a module not in the build list
would add the module to go.mod (with the explicit version string "none").
Subsequent go commands would fail with 'invalid module version "none"'.
Bryan C. Mills [Fri, 3 Aug 2018 17:43:17 +0000 (13:43 -0400)]
cmd/go/internal/load: pass the importer's package path when checking visibility
A module like "gopkg.in/macaroon.v2" might have a test with a "_test" package
suffix (see https://golang.org/cmd/go/#hdr-Test_packages).
When we compile that test, its ImportStack entry includes the "_test" suffix
even though nothing else can actually import it via that path.
When we look up the module containing such a package, we must use the original
path, not the suffixed one.
On the other hand, an actual importable package may also be named with the
suffix "_test", so we need to be careful not to strip the suffix if it is
legitimately part of the path. We cannot distinguish that case by examining
srcDir or the ImportStack: the srcDir contaning a module doesn't necessarily
bear any relationship to its import path, and the ImportStack doesn't tell us
whether the suffix is part of the original path.
Fortunately, LoadImport usually has more information that we can use: it
receives a parent *Package that includes the original import path.
Richard Musiol [Tue, 31 Jul 2018 13:12:57 +0000 (15:12 +0200)]
syscall/js: extend ValueOf to support arrays and objects
This commits adds []interface{} and map[string]interface{} as quick
ways to create JavaScript arrays and objects. They correspond to the
JavaScript notations [...] and {...}. A type alias can be used for
a concise notation.
GIT_TRACE write message to stderr, while run1 merge both stdout and
stderr. So function which call run1 and rely on its output will failed
to parse the result when run1 success.
By using cmd.Output(), we ensure only cmd standard out is returned.
Fixes #19682
Change-Id: I7002df17fe68aea1860ddc7382c68cc23548bd90
Reviewed-on: https://go-review.googlesource.com/126735 Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Ian Lance Taylor [Fri, 3 Aug 2018 21:52:54 +0000 (14:52 -0700)]
cmd/internal/objfile: only consider executable segments for load address
Reportedly on some new Fedora systems the linker is producing extra
load segments, basically making the dynamic section non-executable.
We were assuming that the first load segment could be used to
determine the program's load offset, but that is no longer true.
Use the first executable load segment instead.
Fixes #26369
Change-Id: I5ee31ddeef2e8caeed3112edc5149065a6448456
Reviewed-on: https://go-review.googlesource.com/127895
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Austin Clements [Fri, 3 Aug 2018 15:34:11 +0000 (11:34 -0400)]
runtime: document assumption about wbBufFlush argument slots
gcWriteBarrier and wbBufFlush assume that not writing to an argument
variable is sufficient to not clobber the corresponding argument slot.
This assumption lets us simplify the write barrier assembly code,
speed up the flush path, and reduce the stack usage of the write
barrier.
But it is an assumption, so this CL documents it to make this clear.
Alternatively, we could separate the register spill slots from the
argument slots in the write barrier, but that loses the advantages
above. On the other hand, it's extremely unlikely that we'll change
the behavior of the compiler to start clobbering argument slots (if
anything, we'd probably change it to *not* clobber argument slots even
if you wrote to the arguments).
// package and imports snipped
func TestCache(t *testing.T) {
tmp := os.TempDir()
for i := 0; i < 1000000; i++ {
os.Stat(filepath.Join(tmp, fmt.Sprintf("%d", i)))
}
}
ijt:~/gopath/src/issue26562$ time ~/github/go/bin/go test -count=1
PASS
ok issue26562 9.444s
real 0m10.021s
user 0m2.344s
sys 0m7.835s
ijt:~/gopath/src/issue26562$ time ~/github/go/bin/go test .
ok issue26562 (cached)
real 0m0.802s
user 0m0.551s
sys 0m0.306s
Updates #26562
Updates #26726
Change-Id: I7914ee57dc75bcbd7f0ea01c70bed97d67c810ea
Reviewed-on: https://go-review.googlesource.com/127715
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
math: ensure Erfc is not called with out-of-expected-range arguments on s390x
The existing implementation produces correct results with a wide range of inputs,
but invalid results asymptotically. With this change we ensure correct asymptotic results
on s390x
Fixes #26477
Change-Id: I760c1f8177f7cab2d7622ab9a926dfb1f8113b49
Reviewed-on: https://go-review.googlesource.com/127119 Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
// package and imports snipped
func TestCache(t *testing.T) {
tmp := os.TempDir()
for i := 0; i < 1000000; i++ {
os.Stat(filepath.Join(tmp, fmt.Sprintf("%d", i)))
}
}
ijt:~/gopath/src/issue26562$ time ~/github/go/bin/go test -count=1
PASS
ok issue26562 9.444s
real 0m10.021s
user 0m2.344s
sys 0m7.835s
ijt:~/gopath/src/issue26562$ time ~/github/go/bin/go test .
ok issue26562 (cached)
real 0m0.802s
user 0m0.551s
sys 0m0.306s
Change-Id: I3ce7f7b68bb5b9e802069f277e79e1ed3c162622
Reviewed-on: https://go-review.googlesource.com/127635
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Thu, 2 Aug 2018 19:35:32 +0000 (12:35 -0700)]
go/scanner: continue adding directory to file name
Before CL 97795, when go/scanner saw a //line comment, it would clean
the path and, if the path was relative, prepend the directory from the
file name. This was not the best API because it meant that the
behavior changed based on whether the code was running on Windows or
not, and it meant that information from the //line directive was lost.
So in CL 97795, among other changes, go/scanner was changed to simply
return the filename given in the //line comment.
Unfortunately existing tools such as unparam and unconvert expected
the old behavior. In order to avoid breaking those tools, revert that
part of the change.
Fixes #26671
Change-Id: Ifa06542bd19cda9d682ac33766ab9080444ba050
Reviewed-on: https://go-review.googlesource.com/127658
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Richard Musiol [Thu, 2 Aug 2018 20:39:00 +0000 (22:39 +0200)]
cmd/link/internal/wasm: add Go version as a custom wasm section
The interface between the wasm binary and wasm_exec.js is experimental
and likely to change in the future. Still, there are some early adopters
who experiment with non-web wasm runtimes. They can't use wasm_exec.js
and have to provide their own equivalent. Adding the Go version as a
custom wasm sections allows for them to support a stable Go version and
the latest devel at the same time.
Brad Fitzpatrick [Thu, 2 Aug 2018 20:42:00 +0000 (20:42 +0000)]
encoding/xml: document HTMLAutoClose and HTMLEntity more
They didn't even have public types, which made them pretty mysterious.
Give them types and reference the Decoder, which uses them.
Also, refer them qualified by their package name in the examples, as
we usually do in example*.go files, which usually use package foo_test
specifically so we can show the package names along with the symbols.
Change-Id: I50ebbbf43778c1627bfa526f8824f52c7953454f
Reviewed-on: https://go-review.googlesource.com/127663 Reviewed-by: Bryan C. Mills <bcmills@google.com>
Brad Fitzpatrick [Thu, 2 Aug 2018 19:34:38 +0000 (19:34 +0000)]
syscall: use deprecation convention in package comment, simplify
Change-Id: I612041d31c01d49135947796fe2a09db3e6894d4
Reviewed-on: https://go-review.googlesource.com/127657 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Xudong Zheng [Wed, 1 Aug 2018 21:33:09 +0000 (21:33 +0000)]
syscall/js: move callback helper code to misc/wasm to avoid using eval()
When using the compiled .wasm with misc/wasm/wasm_exec.js, we get an error message if the site prohibits eval() via the Content-Security-Policy header. This can be resolved by moving the callback helper code from src/syscall/js/callback.go to misc/wasm/wasm_exec.js.
David Wimmer [Wed, 25 Jul 2018 18:44:07 +0000 (18:44 +0000)]
runtime: fix syscall error returns on mips/mips64/ppc64
The linux syscall functions used in runtime are designed around the calling
convention of returning errors as negative numbers. On some other systems
(like mips and ppc) the actual syscalls signal errors in other ways. This
means that the assembly implementations of the syscall functions on these
platforms need to transform the return values in the error cases to match
the expected negative errno values. This was addressed for certain syscalls
in https://golang.org/cl/19455 and https://golang.org/cl/89235. This patch
handles the rest of the syscall functions in sys_linux_*.s that return any
value for mips/mips64/ppc64.
Fixes #23446
Change-Id: I302100261231f76d5850ab2c2ea080170d7dba72
GitHub-Last-Rev: e358e2b08c76897b13f917cfa12b5085e20337f9
GitHub-Pull-Request: golang/go#26606
Reviewed-on: https://go-review.googlesource.com/125895
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Wed, 1 Aug 2018 04:31:19 +0000 (21:31 -0700)]
cmd/cgo: stop expanding typedefs once we reach __builtin types
Expanding __builtin types (__builtin_va_list, particularly) leads
to problems because they are expanded by the compiler itself - the
expansions are not generated by anything in a .h file. The types
a __builtin type expand to are thus very confusing to cgo.
See CL 126275.
Change-Id: I66eb6a4f27f652f1b934ba702f580f6daa62a566
Reviewed-on: https://go-review.googlesource.com/127156
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Previously, cmd/doc treated GOROOT/src and GOPATH/src
as the roots of the directory trees holding packages, assuming
that the import path would be the path elements after the src directory.
With modules, each module serves as its own root of a file tree,
and the import path prefix starts with the module path before
adding the path elements after the module root.
There are ways we could make this more efficient,
but for now this is a fairly small adjustment to get 'go doc'
working OK for modules for Go 1.11.
cmd/go: move module cache from $GOPATH/src/mod to $GOPATH/pkg/mod
Using $GOPATH/src/mod confuses too many tools.
$GOPATH/pkg/mod seems better for now.
It's also next to dep's cache, $GOPATH/pkg/dep.
If we do eliminate GOPATH/pkg for holding .a files (#4719)
then we could still keep it around for pkg/mod.
(Or we could move the module cache again then.)
Fixes #26401.
Fixes #26635.
Change-Id: I18f7da216ed9f490eded3c00d837fb086ae5b6a4
Reviewed-on: https://go-review.googlesource.com/126755
Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Rob Pike <r@golang.org>
Relative directory paths have always worked.
This CL makes absolute directory paths be handled the same way.
(It was an oversight that they were excluded.)
It also fixes the case of naming the directory holding source code
for a package in a module dependency.
The old -getmode flag had two settings:
-getmode=local meant don't download from the network.
-getmode=vendor meant only use the vendor directory.
The new -mod flag has two settings:
-mod=readonly means refuse to automatically update go.mod (mainly for CI testing).
-mod=vendor means only use the vendor directory.
The old GOPROXY variable had two settings:
a proxy URL or else the empty string (direct connect).
The new GOPROXY variable has three settings:
a proxy URL, the string "off" (no network use allowed),
or else the empty string or the explicit string "direct" (direct connection).
We anticipate allow a comma-separated sequence in a future release,
so commas are disallowed entirely right now.
People sometimes want to turn on a particular go command flag by default.
In Go 1.11 we have at least two different cases where users may need this.
1. Linking can be noticeably slower on underpowered systems
due to DWARF, and users may want to set -ldflags=-w by default.
2. For modules, some users or CI systems will want vendoring always,
so they want -getmode=vendor (soon to be -mod=vendor) by default.
This CL generalizes the problem to “set default flags for the go command.”
$GOFLAGS can be a space-separated list of flag settings, but each
space-separated entry in the list must be a standalone flag.
That is, you must do 'GOFLAGS=-ldflags=-w' not 'GOFLAGS=-ldflags -w'.
The latter would mean to pass -w to go commands that understand it
(if any do; if not, it's an error to mention it).
cmd/go: change list -compiled to populate new CompiledGoFiles list
CL 108156 added -cgo during the Go 1.11 cycle.
To avoid adding a new field to Package, it redefined the
meaning of the CgoFiles list to be the cgo output instead
of the cgo input.
This was awkward in the go command itself, since the meaning
of the list changed midway through the build.
But, worse, it is awkward to users of go list.
When gathering information about a tree of packages,
we may want the names of both the cgo inputs and the cgo outputs
(golang.org/x/tools/go/packages does, it turns out),
or when combined with -deps (CL 107776),
we may only care about one list or the other depending
on whether the package was requested explicitly or is
being returned as a dependency.
Also, it's not general enough. SWIGFiles turn into cgo files
and then end up in the list too. And maybe there will be others
in the future. What clients really want is the list of files that
are presented to the go compiler, so that they can parse
and type-check them as if they were the compiler instead.
Eliminate all this awkwardness by dropping -cgo and adding
a new -compiled that populates a new CompiledGoFiles list.
Change-Id: I5f152da17cfb2692eedde61721d01ec13067c57d
Reviewed-on: https://go-review.googlesource.com/126695
Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
The current "go mod" command does too many things.
The design is unclear.
It looks like "everything you might want to do with modules"
which causes people to think all module operations go through
"go mod", which is the opposite of the seamless integration we're
going for. In particular too many people think "go mod -require"
and "go get" are the same.
It does make sense to put the module-specific functionality
under "go mod", but not as flags. Instead, split "go mod" into
multiple subcommands:
go mod edit # old go mod -require ...
go mod fix # old go mod -fix
go mod graph # old go mod -graph
go mod init # old go mod -init
go mod tidy # old go mod -sync
go mod vendor # old go mod -vendor
go mod verify # old go mod -verify
Splitting out the individual commands makes both the docs
and the implementations dramatically easier to read.
It simplifies the command lines
(go mod -init -module m is now 'go mod init m')
and allows command-specific flags.
We've avoided subcommands in the go command to date, and we
should continue to avoid adding them unless it really makes
the experience significantly better. In this case, it does.
Creating subcommands required some changes in the core
command-parsing and help logic to generalize from one
level to multiple levels.
As part of having "go mod init" be a separate command,
this CL changes the failure behavior during module initialization
to be delayed until modules are actually needed.
Initialization can still happen early, but the base.Fatalf
is delayed until something needs to use modules.
This fixes a bunch of commands like 'go env' that were
unhelpfully failing with GO111MODULE=on when not in a
module directory.
We aren't planning to use this or advertise it much yet,
but having support for it now will make it easier to start
using in the future - older go commands will understand
what 'go 1.20' means and that they don't have go 1.20.
Saves ~105KB of heap for callers who don't use html.UnescapeString.
(EscapeString is much more common).
Also saves 70KB of binary size, because now the linker can do dead
code elimination. (because #2559 is still open and global maps always
generate init code)
Kir Kolyshkin [Mon, 30 Jul 2018 14:05:49 +0000 (17:05 +0300)]
cmd/cgo: add column number to line directives
Due to a new specification of //line: directives, missing
column info is now treated as column 0, aka "unknown column"
(see https://github.com/golang/go/issues/24183 for details).
As cgo does not add column number to generated //line: directive,
resulting files parsed do not have column info.
Fix by adding column of 1 to generated line directives.
Fixes #26692
Change-Id: Ie9263c0cf666b92d19c34240e745e8f32ffe7174
Reviewed-on: https://go-review.googlesource.com/126675
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Thu, 26 Jul 2018 23:33:27 +0000 (16:33 -0700)]
cmd/cgo: make sure we FinishType everything
Ensure that we call FinishType on all the types added to the ptrs map.
We only add a key to ptrKeys once. Once we FinishType for that key,
we'll never look at that key again. But we can add a new type under that
key later, and we'll never finish it.
Make sure we add the key to the ptrKeys list every time we make the list
of types for that key non-empty.
This makes sure we FinishType each pointer type exactly once.
Fixes #26517
Change-Id: Iad86150d516fcfac167591daf5a26c38bec7d143
Reviewed-on: https://go-review.googlesource.com/126275 Reviewed-by: Ian Lance Taylor <iant@golang.org>
cmd/go/internal/modfetch/codehost: quote arguments to commands printed from -x
Some of the arguments — particularly format strings passed to git commands — may
contain spaces, and it's useful to be able to paste commands from 'go get -x
foo' directly into a shell to reproduce their output.
Richard Musiol [Sat, 28 Jul 2018 11:45:02 +0000 (13:45 +0200)]
syscall: remove support for O_NONBLOCK and O_SYNC on js/wasm
This commit removes O_NONBLOCK on js/wasm. O_SYNC can't be
removed, because it is referenced by the os package, so instead
its use returns an error.
On Windows, the options O_NONBLOCK and O_SYNC are not available
when opening a file with Node.js. This caused the initialization
of the syscall package to panic.
The simplest solution is to not support these two options on js/wasm
at all. Code written for js/wasm is supposed to be portable,
so platform-specific options should not be used.
Richard Musiol [Tue, 31 Jul 2018 13:17:31 +0000 (15:17 +0200)]
syscall/js: improve documentation about mappings to JavaScript values
This commit moves the documentation about how Go values are mapped to
JavaScript values to the functions that apply the mapping, instead of
mentioning them in the documentation of the types being mapped. This
should be easier to read.
Roger Peppe [Fri, 20 Jul 2018 10:31:39 +0000 (11:31 +0100)]
go/doc: do not treat methods as test functions
The example code was treating a method starting with Test
as a test function when considering whether to produce
a whole-file example or not. As a method can never be
a test function, this isn't correct.
Change-Id: Idd8ec9eaf0904af076e941d7fe7d967f6b7eef78
Reviewed-on: https://go-review.googlesource.com/125257 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Paul Jolly [Mon, 30 Jul 2018 21:31:01 +0000 (22:31 +0100)]
doc: add link to go command modules docs from Go 1.11 release notes
The FAQ already has a link to the release notes and the go command docs.
Add a link from the release notes to the go command docs, to ensure that
people ultimately end up there (the docs that then signpost
people to the relevant other help docs).
cmd/go: forbid use of one module with two different paths
If a single module is imported via two different paths (e.g., as itself and as a
replacement for something else), some users may be surprised if the two paths
do not share the same package-level state. Others may be surprised if the two
paths do share state.
Punt on the question for now by rejecting that condition explicitly.
cmd/go/internal/modload: inline doImport into doPkg
doImport is itself a thin wrapper around Import, and doPkg is its only call
site. I'm having trouble following what doPkg is doing due to the indirection,
so I'm removing it.
Michael Matloob [Fri, 27 Jul 2018 20:23:16 +0000 (16:23 -0400)]
cmd/go: add test code packages in list -test
Previously go list -test <pkg> would return pkg and, if it exists,
pkg.test, the test main package. This change will also list the
two test code packages (if they exist) that contain testing functions,
<pkg> [<pkg>.test] and <pkg>_test [<pkg>.test].
These packages which contain testing code are usually the packages
go list users desire to know about, so they should be surfaced
in go list -test.