]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
6 years agolib/time: follow redirects in curl
Kyle Shannon [Wed, 24 Jan 2018 00:54:57 +0000 (17:54 -0700)]
lib/time: follow redirects in curl

Starting on or about the 2018c archives, www.iana.org is redirected to
data.iana.org.  Tell curl to follow the redirect.

Updates: #22487

Change-Id: I00acada1a3ba01ef701d6d4ffae6cc2cbb6a068f
Reviewed-on: https://go-review.googlesource.com/89375
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: don't let spills clobber arguments
Keith Randall [Tue, 23 Jan 2018 21:06:21 +0000 (13:06 -0800)]
cmd/compile: don't let spills clobber arguments

The compiler allows code to have multiple differently-typed views of a
single argument. For instance, if we have

func f(x float64) {
   y := *(*int64)(unsafe.Pointer(&x))
   ...
}

Then in SSA we get two OpArg ops, one with float64 type and one with
int64 type.

The compiler will try to reuse argument slots for spill slots. It
checks that the argument slot is dead by consulting an interference
graph.

When building the interference graph, we normally ignore cross-type
edges because the values on either end of that edge can't be allocated
to the same slot. (This is just a space-saving optimization.) This
rule breaks down when one of the values is an argument, because of the
multiple views described above. If we're spilling a float64, it is not
enough that the float64 version of x is dead; the int64 version of x
has to be dead also.

Remove the optimization of not recording interference edges if types
don't match. That optimization is incorrect if one of the values
connected by the edge is an argument.

Fixes #23522

Change-Id: I361f85d80fe3bc7249014ca2c3ec887c3dc30271
Reviewed-on: https://go-review.googlesource.com/89335
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agogo/types: more robust behavior in the presence errors (due to import "C")
Robert Griesemer [Fri, 19 Jan 2018 01:45:58 +0000 (17:45 -0800)]
go/types: more robust behavior in the presence errors (due to import "C")

- Don't complain about invalid constant type if the type is
  invalid already (we do this in other places as well). This
  is useful to do in general, and even more so if we have
  invalid types due to import "C".

- Type-check the lhs of an assignment even if we bail out early
  due to an error on the rhs. This was simply an oversight. We
  already have machinery in place to "use" expressions; in this
  case we just have to also make sure we don't overcount "uses"
  of variables on the lhs.

- Fix overcount uses correction in assignments: Only do it if
  the variable in question is declared inside the same package
  to avoid possible race conditions when type-checking exported
  variables concurrently.

Fixes #22090.

Change-Id: I4c1b59f9ce38970e7129fedc5f6023908386e4f1
Reviewed-on: https://go-review.googlesource.com/88375
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agoruntime: never allocate during an unrecoverable panic
Austin Clements [Thu, 18 Jan 2018 19:58:05 +0000 (14:58 -0500)]
runtime: never allocate during an unrecoverable panic

Currently, startpanic_m (which prepares for an unrecoverable panic)
goes out of its way to make it possible to allocate during panic
handling by allocating an mcache if there isn't one.

However, this is both potentially dangerous and unnecessary.
Allocating an mcache is a generally complex thing to do in an already
precarious situation. Specifically, it requires obtaining the heap
lock, and there's evidence that this may be able to deadlock (#23360).
However, it's also unnecessary because we never allocate from the
unrecoverable panic path.

This didn't use to be the case. The call to allocmcache was introduced
long ago, in CL 7388043, where it was in preparation for separating Ms
and Ps and potentially running an M without an mcache. At the time,
after calling startpanic, the runtime could call String and Error
methods on panicked values, which could do anything including
allocating. That was generally unsafe even at the time, and CL 19792
fixed this be pre-printing panic messages before calling startpanic.
As a result, we now no longer allocate after calling startpanic.

This CL not only removes the allocmcache call, but goes a step further
to explicitly disallow any allocation during unrecoverable panic
handling, even in situations where it might be safe. This way, if
panic handling ever does an allocation that would be unsafe in unusual
circumstances, we'll know even if it happens during normal
circumstances.

This would help with debugging #23360, since the deadlock in
allocmcache is currently masking the real failure.

Beyond all.bash, I manually tested this change by adding panics at
various points in early runtime init, signal handling, and the
scheduler to check unusual panic situations.

Change-Id: I85df21e2b4b20c6faf1f13fae266c9339eebc061
Reviewed-on: https://go-review.googlesource.com/88835
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: don't grow the stack on sigpanic if throwsplit
Austin Clements [Fri, 12 Jan 2018 17:03:49 +0000 (12:03 -0500)]
runtime: don't grow the stack on sigpanic if throwsplit

Currently, if a _SigPanic signal arrives in a throwsplit context,
nothing is stopping the runtime from injecting a call to sigpanic that
may attempt to grow the stack. This will fail and, in turn, mask the
real problem.

Fix this by checking for throwsplit in the signal handler itself
before injecting the sigpanic call.

Updates #21431, where this problem is likely masking the real problem.

Change-Id: I64b61ff08e8c4d6f6c0fb01315d7d5e66bf1d3e2
Reviewed-on: https://go-review.googlesource.com/87595
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agospec: consistently use "defined type" and "type name" (cleanup)
Robert Griesemer [Tue, 23 Jan 2018 00:20:01 +0000 (16:20 -0800)]
spec: consistently use "defined type" and "type name" (cleanup)

When we introduced the notion of alias type declarations, we renamed
"named type" to "defined type" to avoid confusion with types denoted
by aliases and thus are also types with names, or "named types".

Some of the old uses of "named types" remained; this change removes
them.

Now the spec consistently uses the terms:

- "defined type"  for a type declared via a type definition
- "type name"     for any name denoting an (alias or defined) type
- "alias"         for a type name declared in an alias declaration

New prose is encouraged to avoid the term "named type" to counter-
act further confusion.

Fixes #23474.

Change-Id: I5fb59f1208baf958da79cf51ed3eb1411cd18e03
Reviewed-on: https://go-review.googlesource.com/89115
Reviewed-by: Rob Pike <r@golang.org>
6 years agocmd/internal/obj/arm64: fix assemble VLD1/VST1 bug
fanzha02 [Tue, 16 Jan 2018 03:00:04 +0000 (03:00 +0000)]
cmd/internal/obj/arm64: fix assemble VLD1/VST1 bug

The current code misassembles VLD1/VST1 instruction with non-zero
offset. The offset is dropped silently without any error message.
The cause of the misassembling is the current code treats argument
(Rn)(Rm) as ZOREG type.

The fix changes the matching rules and considers (Rn)(Rm) as ROFF
type. The fix will report error information when assembles VLD1/VST1
(R8)(R13), [V1.16B].
The fix enables the ARM64Errors test.

Fixes #23448

Change-Id: I3dd518b91e9960131ffb8efcb685cb8df84b70eb
Reviewed-on: https://go-review.googlesource.com/87956
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agodoc, cmd/go: final release notes edits
Russ Cox [Mon, 22 Jan 2018 17:56:01 +0000 (12:56 -0500)]
doc, cmd/go: final release notes edits

Except for removing the DRAFT marker, I think these are now ready to go.

Change-Id: I20604f5b135616189a24990db463c7bb5e7d48f1
Reviewed-on: https://go-review.googlesource.com/88975
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoos: handle ' is a directory' error as IsExist on Plan 9
Fazlul Shahriar [Sun, 21 Jan 2018 18:49:41 +0000 (13:49 -0500)]
os: handle ' is a directory' error as IsExist on Plan 9

This error is returned by os.Mkdir when the directory already exists.

This change fixes some upspin tests.

Change-Id: I9ad5aefebb32dff577726d537b4f3826d79868eb
Reviewed-on: https://go-review.googlesource.com/88656
Reviewed-by: David du Colombier <0intro@gmail.com>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/dist: only run swig tests when a go directory is present in swiglib
Martin Möhrmann [Fri, 19 Jan 2018 17:26:58 +0000 (18:26 +0100)]
cmd/dist: only run swig tests when a go directory is present in swiglib

When there is no go directory inside the swiglib directory then swig
was installed without Go support. Tests in misc/swig will fail when
swig is installed without Go support.

Add additional checks for the presence of a go directory in the directory
reported by 'swig -go -swiglib' to determine if misc/swig tests should
be run.

This avoids all.bash failing when swig but not swig-go is installed
using macports.

Tested on darwin with swig and with and without swig-go installed
using macports.

Fixes #23469

Change-Id: I173201221554982ea0d9f2bea70a3cb85b297cec
Reviewed-on: https://go-review.googlesource.com/88776
Reviewed-by: David Chase <drchase@google.com>
6 years agodoc: document Go 1.8.6
Andrew Bonventre [Tue, 23 Jan 2018 02:01:18 +0000 (21:01 -0500)]
doc: document Go 1.8.6

Update golang/go#23515

Change-Id: Id334d8663bf4cbb68f224d1bba4c9ad3855f8aae
Reviewed-on: https://go-review.googlesource.com/89155
Reviewed-by: Andrew Gerrand <adg@golang.org>
6 years agocmd/go: apply "go vet" to test files
Ian Lance Taylor [Fri, 12 Jan 2018 23:54:09 +0000 (15:54 -0800)]
cmd/go: apply "go vet" to test files

In earlier versions of Go the "go vet" command would run on regular
source files and test files. That was lost in CL74750.  Bring it back.

This required moving a chunk of code from internal/test to
internal/load. The diff looks big but the code is unchanged.

Fixes #23395

Change-Id: Ie9ec183337e8db81c5fc421d118a22b351b5409e
Reviewed-on: https://go-review.googlesource.com/87636
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoruntime: print hexdump on traceback failure
Austin Clements [Mon, 22 Jan 2018 19:53:36 +0000 (14:53 -0500)]
runtime: print hexdump on traceback failure

Currently, if anything goes wrong when printing a traceback, we simply
cut off the traceback without any further diagnostics. Unfortunately,
right now, we have a few issues that are difficult to debug because
the traceback simply cuts off (#21431, #23484).

This is an attempt to improve the debuggability of traceback failure
by printing a diagnostic message plus a hex dump around the failed
traceback frame when something goes wrong.

The failures look like:

goroutine 5 [running]:
runtime: unexpected return pc for main.badLR2 called from 0xbad
stack: frame={sp:0xc42004dfa8, fp:0xc42004dfc8} stack=[0xc42004d800,0xc42004e000)
000000c42004dea8:  0000000000000001  0000000000000001
000000c42004deb8:  000000c42004ded8  000000c42004ded8
000000c42004dec8:  0000000000427eea <runtime.dopanic+74>  000000c42004ded8
000000c42004ded8:  000000000044df70 <runtime.dopanic.func1+0>  000000c420001080
000000c42004dee8:  0000000000427b21 <runtime.gopanic+961>  000000c42004df08
000000c42004def8:  000000c42004df98  0000000000427b21 <runtime.gopanic+961>
000000c42004df08:  0000000000000000  0000000000000000
000000c42004df18:  0000000000000000  0000000000000000
000000c42004df28:  0000000000000000  0000000000000000
000000c42004df38:  0000000000000000  000000c420001080
000000c42004df48:  0000000000000000  0000000000000000
000000c42004df58:  0000000000000000  0000000000000000
000000c42004df68:  000000c4200010a0  0000000000000000
000000c42004df78:  00000000004c6400  00000000005031d0
000000c42004df88:  0000000000000000  0000000000000000
000000c42004df98:  000000c42004dfb8  00000000004ae7d9 <main.badLR2+73>
000000c42004dfa8: <00000000004c6400  00000000005031d0
000000c42004dfb8:  000000c42004dfd0 !0000000000000bad
000000c42004dfc8: >0000000000000000  0000000000000000
000000c42004dfd8:  0000000000451821 <runtime.goexit+1>  0000000000000000
000000c42004dfe8:  0000000000000000  0000000000000000
000000c42004dff8:  0000000000000000
main.badLR2(0x0)
/go/src/runtime/testdata/testprog/badtraceback.go:42 +0x49

For #21431, #23484.

Change-Id: I8718fc76ced81adb0b4b0b4f2293f3219ca80786
Reviewed-on: https://go-review.googlesource.com/89016
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agodoc: update 1.9.3 release date
Andrew Bonventre [Mon, 22 Jan 2018 20:36:24 +0000 (15:36 -0500)]
doc: update 1.9.3 release date

Change-Id: I689ccfb8452a170629425dc97da503b28766c6f9
Reviewed-on: https://go-review.googlesource.com/89035
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/go1.10: address final TODOs
Russ Cox [Thu, 18 Jan 2018 15:22:11 +0000 (10:22 -0500)]
doc/go1.10: address final TODOs

Change-Id: Id71c1ccb584fb308f1615c0ed1255cc8b44bf675
Reviewed-on: https://go-review.googlesource.com/88256
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/vendor/github.com/google/pprof/internal/driver: skip read only dir error on Android
Elias Naur [Sun, 21 Jan 2018 11:16:49 +0000 (12:16 +0100)]
cmd/vendor/github.com/google/pprof/internal/driver: skip read only dir error on Android

On an android/amd64 emulator, $HOME points to / which is not writable.
Ignore the error in the pprof driver test.

With this, androidtest.sh on android/amd64 and android/386 passes.

Upstream pull request https://github.com/google/pprof/pull/295.

Change-Id: If919d7f44530a977fd044631ad01bac87d32deaa
Reviewed-on: https://go-review.googlesource.com/88817
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
6 years agocmd/go: add go help cache
Russ Cox [Tue, 9 Jan 2018 21:31:12 +0000 (16:31 -0500)]
cmd/go: add go help cache

Change-Id: I14eeda85f279d1082ea9f2ac590b848ac13b1daa
Reviewed-on: https://go-review.googlesource.com/87023
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agoruntime: pass dummy argc/argv correctly in r0_386_android_lib
Ian Lance Taylor [Fri, 19 Jan 2018 18:56:59 +0000 (10:56 -0800)]
runtime: pass dummy argc/argv correctly in r0_386_android_lib

Fix breakage introduced in CL 70530.

Change-Id: I87f3da6b20554d4f405a1143b0d894c5953b63aa
Reviewed-on: https://go-review.googlesource.com/88516
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
6 years agomisc,src: add support for specifying adb flags to the android harness
Elias Naur [Sat, 20 Jan 2018 18:56:51 +0000 (19:56 +0100)]
misc,src: add support for specifying adb flags to the android harness

Introduce GOANDROID_ADB_FLAGS for additional flags to adb invocations.
With GOANDROID_ADG_FLAGS, the Android builders can distinguish between
emulator and device builds.

Change-Id: I11729926a523ee27f6a3795cb2cfb64a9454f0a5
Reviewed-on: https://go-review.googlesource.com/88795
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
6 years agodoc: change anchor URLs from golang.org/dl/ to /dl/
Andrew Bonventre [Sat, 20 Jan 2018 03:47:23 +0000 (22:47 -0500)]
doc: change anchor URLs from golang.org/dl/ to /dl/

When running locally, it will redirect properly to golang.org/dl/
(see https://github.com/golang/tools/blob/master/cmd/godoc/dl.go).

This is to support domains in prod other than golang.org.

Change-Id: I6d3051fcd7e06a86442324a64d781d8ad95c624f
Reviewed-on: https://go-review.googlesource.com/88679
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/faq: clarify that concurrent maps reads are safe
Ian Lance Taylor [Fri, 19 Jan 2018 17:34:24 +0000 (09:34 -0800)]
doc/faq: clarify that concurrent maps reads are safe

Fixes #23480

Change-Id: I33b4bdc60b9983ab62d87bfa0ae3ff33304269c0
Reviewed-on: https://go-review.googlesource.com/88515
Reviewed-by: Rob Pike <r@golang.org>
6 years agodoc: document Go 1.9.3
Andrew Bonventre [Fri, 19 Jan 2018 17:50:40 +0000 (12:50 -0500)]
doc: document Go 1.9.3

Change-Id: Ic7a5d3118754b34ab0652fcef889259a03baebc3
Reviewed-on: https://go-review.googlesource.com/88536
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/fix: add intermediate cast for *C.CFTypeRef <-> *unsafe.Pointer
Keith Randall [Thu, 18 Jan 2018 02:46:47 +0000 (18:46 -0800)]
cmd/fix: add intermediate cast for *C.CFTypeRef <-> *unsafe.Pointer

When casting between *C.CFTypeRef and *unsafe.Pointer, we used to be
able to do the cast directly. Now with C.CFTypeRef being a uintptr
instead of an unsafe.Pointer, we need an intermediate cast.

Add the insertion of the intermediate cast to the cftype fix module.

Fixes #23091

Change-Id: I891be2f4a08cfd7de1cc4c6ab841b1e0d8c388a6
Reviewed-on: https://go-review.googlesource.com/88175
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocrypto/x509: better document Verify's behaviour.
Adam Langley [Wed, 10 Jan 2018 22:26:33 +0000 (14:26 -0800)]
crypto/x509: better document Verify's behaviour.

This change expands the documentation for Verify to mention the name
constraints and EKU behaviour.

Change-Id: Ifc80faa6077c26fcc1d2a261ad1d14c00fd13b23
Reviewed-on: https://go-review.googlesource.com/87300
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: don't combine 64-bit loads/stores on amd64
Caleb Spare [Wed, 17 Jan 2018 20:13:45 +0000 (12:13 -0800)]
cmd/compile: don't combine 64-bit loads/stores on amd64

This causes a performance regression for some calls.

Fixes #23424.
Updates #6853.

Change-Id: Id1db652d5aca0ce631a3417c0c056d6637fefa9e
Reviewed-on: https://go-review.googlesource.com/88135
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/fix: don't depend on *GetTypeID functions being present
Keith Randall [Wed, 17 Jan 2018 18:38:10 +0000 (10:38 -0800)]
cmd/fix: don't depend on *GetTypeID functions being present

cgo uses the presence of these functions to determine whether
a given type is in the CFTypeRef hierarchy and thus should be
a uintptr instead of a pointer. But if the *GetTypeID functions
aren't used by the user code, then they won't be present in the
cgo output, and thus cmd/fix won't see them.

Use the simpler rule that anything ending in *Ref should be
rewritten. This could over-rewrite, but I don't see a simpler
solution. Unlike cgo, it is easy to edit the output to fix any
issues. And fix is a much rarer operation than cgo.

This is a revert of portions of CL 87616.

Update #23091

Change-Id: I74ecd9fb25490a3d279b372e107248452bb62185
Reviewed-on: https://go-review.googlesource.com/88075
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agospec: mention that special case for integer division is due to overflow
Robert Griesemer [Wed, 17 Jan 2018 05:30:46 +0000 (21:30 -0800)]
spec: mention that special case for integer division is due to overflow

Fixes #23443.

Change-Id: If60c39b582ee5308e9fa902f93c1b6ae7890346c
Reviewed-on: https://go-review.googlesource.com/87975
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agocmd/fix: extend typechecker to use cgo types
Keith Randall [Fri, 12 Jan 2018 18:11:01 +0000 (10:11 -0800)]
cmd/fix: extend typechecker to use cgo types

If a file uses cgo, incorporate the types generated by running cgo.

Update #23091

Change-Id: I10958fa7fd6027c2c96a9fd8a9658de35439719f
Reviewed-on: https://go-review.googlesource.com/87616
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocmd/cgo: rewrite CFTypeRef and subytes on Darwin to uintptr
Keith Randall [Fri, 12 Jan 2018 18:08:38 +0000 (10:08 -0800)]
cmd/cgo: rewrite CFTypeRef and subytes on Darwin to uintptr

Cgo currently maps CFTypeRef and its subtypes to unsafe.Pointer
or a pointer to a named empty struct.

However, Darwin sometimes encodes some of CFTypeRef's subtypes as a
few int fields packed in a pointer wrapper. This hackery confuses the
Go runtime as the pointers can look like they point to things that
shouldn't be pointed at.

Switch CFTypeRef and its subtypes to map to uintptr.

Detecting the affected set of types is tricky, there are over 200 of
them, and the set isn't static across Darwin versions. Fortunately,
downcasting from CFTypeRef to a subtype requires calling CFGetTypeID,
getting a CFTypeID token, and comparing that with a known id from a
*GetTypeID() call. So we can find all the type names by detecting all
the *GetTypeID() prototypes and rewriting the corresponding *Ref types
to uintptr. This strategy covers all the cases I've checked and is
unlikely to have a false positive.

Update #23091.

Change-Id: I487eb4105c9b4785ba564de9c38d472c8c9a76ac
Reviewed-on: https://go-review.googlesource.com/87615
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agosync: consistently use article "a" for RWMutex
Brad Fitzpatrick [Tue, 16 Jan 2018 22:57:44 +0000 (22:57 +0000)]
sync: consistently use article "a" for RWMutex

We used a mix of both before.

I've never heard anybody say "an arr-double you mutex" when speaking.

Fixes #23457

Change-Id: I802b5eb2339f885ca9d24607eeda565763165298
Reviewed-on: https://go-review.googlesource.com/87896
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agoruntime: fix time.Now on Sierra and older
Giovanni Bajo [Sat, 13 Jan 2018 01:22:05 +0000 (02:22 +0100)]
runtime: fix time.Now on Sierra and older

CL 67332 created the fast no-syscall path for time.Now in High Sierra
but managed to break Sierra and older by forcing them into the slow
syscall path: the version check based on commpage version was wrong.

This CL uses the Darwin version number instead.

The assembly diff is noisy because many variables had to be
renamed, but the only actual change is the version check.

Fixes #23419.

Change-Id: Ie31ef5fb88f66d1517a8693942a7fb6100c213b0
Reviewed-on: https://go-review.googlesource.com/87655
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agoruntime: update URL of the Linux vDSO parser tool
Tobias Klauser [Tue, 16 Jan 2018 11:44:52 +0000 (12:44 +0100)]
runtime: update URL of the Linux vDSO parser tool

The tool was moved to tools/Testing/selftests within the Linux kernel
source tree. Adjust the URL in the comments of vdso_linux.go

Change-Id: I86b9cae4b898c4a45bc7c54891ce6ead91a22670
Reviewed-on: https://go-review.googlesource.com/87815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: specify which pprof version was vendored in go1.10
Alberto Donizetti [Mon, 15 Jan 2018 13:17:43 +0000 (14:17 +0100)]
doc: specify which pprof version was vendored in go1.10

Change-Id: I248cb10a2e24f089600c13e86da251970c773d95
Reviewed-on: https://go-review.googlesource.com/87662
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: don't issue cgocheck error for timer bucket source pointer
Ian Lance Taylor [Sat, 13 Jan 2018 00:29:48 +0000 (16:29 -0800)]
runtime: don't issue cgocheck error for timer bucket source pointer

The cgo checker was issuing an error with cgocheck=2 when a timer
bucket was stored in a pollDesc. The pollDesc values are allocated
using persistentalloc, so they are not in the Go heap. The code is OK
since timer bucket pointers point into a global array, and as such are
never garbage collected or moved.

Mark timersBucket notinheap to avoid the problem. timersBucket values
only occur in the global timers array.

Fixes #23435

Change-Id: I835f31caafd54cdacc692db5989de63bb49e7697
Reviewed-on: https://go-review.googlesource.com/87637
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go: clarify and simplify (a little) the description of go test's caching
Rob Pike [Mon, 15 Jan 2018 01:52:48 +0000 (12:52 +1100)]
cmd/go: clarify and simplify (a little) the description of go test's caching

I found the previous text choppy and hard to follow, and in putting
this CL together, based entirely on the existing text, I found
several details that seemed misleading to me.

This is my attempt to make the text simultaneously easier to
understand, more complete, and more precise. I may have failed in
all three, but I wanted to try.

Change-Id: I088cb457f6fcad8f2b40236949cc3ac43455e600
Reviewed-on: https://go-review.googlesource.com/87735
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agonet/rpc: improve error report messages
Kunpei Sakai [Wed, 10 Jan 2018 23:45:03 +0000 (08:45 +0900)]
net/rpc: improve error report messages

Updates #19957

Change-Id: I8e2e3837db9e5e69b7102f9bd5831fe78ac60cfc
Reviewed-on: https://go-review.googlesource.com/87335
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agocmd/go: use Windows %AppData% for build cache if %LocalAppData% is empty
Brad Fitzpatrick [Sat, 13 Jan 2018 15:28:42 +0000 (15:28 +0000)]
cmd/go: use Windows %AppData% for build cache if %LocalAppData% is empty

Fixes #23190

Change-Id: I96805aaab44ddaae6098b4e3af30f9e52585eae0
Reviewed-on: https://go-review.googlesource.com/87675
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: make gccgo -buildmode=shared and -linkshared work again
Ian Lance Taylor [Fri, 12 Jan 2018 02:22:23 +0000 (18:22 -0800)]
cmd/go: make gccgo -buildmode=shared and -linkshared work again

After CL 69831, addTransitiveLinkDeps ensures that all dependencies of
a link appear in Deps. We no longer need to traverse through all
actions to find them. And the old scheme of looking through all the
actions and assuming we would see shared library actions before
libraries they depend on no longer works.

Now that we have complete deps, change to a simpler scheme in which we
find the shared libraries in the deps, and then use that to sort the
deps into archives and shared libraries.

Fixes #22224

Change-Id: I14fcc773ac59b6f5c2965cc04d4ed962442cc89e
Reviewed-on: https://go-review.googlesource.com/87497
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/compile: document reserved import paths
Robert Griesemer [Fri, 12 Jan 2018 01:37:16 +0000 (17:37 -0800)]
cmd/compile: document reserved import paths

Fixes #20708.

Change-Id: I2db450947b64b8b5af3822c7fbcc3e99746ae9d7
Reviewed-on: https://go-review.googlesource.com/87496
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agospec: remove example explaining that type B0 and B0 are identical
Robert Griesemer [Thu, 11 Jan 2018 18:41:03 +0000 (10:41 -0800)]
spec: remove example explaining that type B0 and B0 are identical

Every few months we get a new error report claiming that there
is a typo in the spec related to this specific example. Clearly,
the fact that two types with the same identifier are identical
seems exceedingly obvious to readers; thus the example seems not
worth the trouble. Removing it.

For #9226.
For #22202.
For #22495.
For #23096.
For #23409.

There may be more.

Change-Id: I003ba79dc460ffb028a4ecb5f29efd60f2551912
Reviewed-on: https://go-review.googlesource.com/87417
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agomisc/cgo/test: avoid endless loop when we can't parse notes
Ian Lance Taylor [Thu, 11 Jan 2018 17:53:56 +0000 (09:53 -0800)]
misc/cgo/test: avoid endless loop when we can't parse notes

Change-Id: I085870d978a3a560588711882c77060d136d867a
Reviewed-on: https://go-review.googlesource.com/87415
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go: correct buildmode test (from "c-header" to "c-shared")
Ian Lance Taylor [Thu, 11 Jan 2018 01:48:37 +0000 (17:48 -0800)]
cmd/go: correct buildmode test (from "c-header" to "c-shared")

Change-Id: I8688a47ae83f6719f6134c64fb3d3f2aa275c641
Reviewed-on: https://go-review.googlesource.com/87158
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agodoc, api: add type Srcset string change to go1.10 notes and API go1.10beta2
Andrew Bonventre [Thu, 11 Jan 2018 16:30:49 +0000 (11:30 -0500)]
doc, api: add type Srcset string change to go1.10 notes and API

Change-Id: I13afaa894292bd566510b40a5e4bbbe4d72d4d08
Reviewed-on: https://go-review.googlesource.com/87395
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocrypto/x509: parse multiple URLs in a single CRLDP.
Adam Langley [Wed, 10 Jan 2018 21:59:51 +0000 (13:59 -0800)]
crypto/x509: parse multiple URLs in a single CRLDP.

Previously we would only extract a single URL from a given CRLDP, but
https://tools.ietf.org/html/rfc5280#section-4.2.1.13 permits multiple
URLs for a single distribution point.

Fixes #23403

Change-Id: I2eaed1537df02d0627db1b86bcd9c94506236bea
Reviewed-on: https://go-review.googlesource.com/87299
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet/http: avoid for-loop if possible
Kunpei Sakai [Thu, 11 Jan 2018 00:58:16 +0000 (09:58 +0900)]
net/http: avoid for-loop if possible

Change-Id: I01900c3a2ebdda8c90d0585f179a39ee890c417f
Reviewed-on: https://go-review.googlesource.com/87336
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile/internal/syntax: don't record semi position if there's none
Robert Griesemer [Thu, 11 Jan 2018 01:14:20 +0000 (17:14 -0800)]
cmd/compile/internal/syntax: don't record semi position if there's none

Fixes #23406.

Change-Id: Ief04e20357c9ca03a5e496f1742428394c8ee658
Reviewed-on: https://go-review.googlesource.com/87317
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocrypto: clarify that some files come from CRYPTOGAMS
Ian Lance Taylor [Wed, 10 Jan 2018 23:45:18 +0000 (15:45 -0800)]
crypto: clarify that some files come from CRYPTOGAMS

and that they are covered by the CRYPTOGAMS license.

Fixes #22637

Change-Id: I75b8e08d3a8b569edf383c078bb11c796b766c81
Reviewed-on: https://go-review.googlesource.com/87315
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet/http: redirect host-based patterns to trailing slash
Terin Stock [Mon, 18 Dec 2017 23:17:02 +0000 (15:17 -0800)]
net/http: redirect host-based patterns to trailing slash

Handlers can be registered for specific hosts by specifying the host as
part of the mux pattern. If a trailing slash route is registered for
these host-based patterns, shouldRedirect should indicate that
a redirect is required.

This change modifies shouldRedirect to also take the host of the
request, and now considers host-based patterns while determining if
a request should be redirected.

Fixes #23183
Change-Id: If8753e130d5d877acdc55344833e3b289bbed2b4
Reviewed-on: https://go-review.googlesource.com/84695
Reviewed-by: Kunpei Sakai <namusyaka@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agonet/http: fix "http2: no cached connection..." error with x/net/http2
Brad Fitzpatrick [Wed, 10 Jan 2018 21:50:13 +0000 (21:50 +0000)]
net/http: fix "http2: no cached connection..." error with x/net/http2

The net/http Transport was testing for a sentinel x/net/http2 error
value with ==, which meant it was only testing the bundled version. If
a user enabled http2 via golang.org/x/net/http2, the error value had a
different name.

This also updates the bundled x/net/http2 to git rev ab555f36 for:

    http2: add internal function isNoCachedConnError to test for ErrNoCachedConn
    https://golang.org/cl/87297

Fixes #22091

Change-Id: I3fb85e2b7ba7d145dd66767e1795a56de633958c
Reviewed-on: https://go-review.googlesource.com/87298
Reviewed-by: Tom Bergan <tombergan@google.com>
6 years agocmd/cgo: support niladic macros for gccgo
Ian Lance Taylor [Sat, 6 Jan 2018 00:52:53 +0000 (16:52 -0800)]
cmd/cgo: support niladic macros for gccgo

https://golang.org/cl/43970 changed writeOutputFunc to support niladic
function-like macros; apply the corresponding change to
writeGccgoOutputFunc.

Updates #10715
Updates #18720

Change-Id: I5decb1d37ec71507466ade2eeda4b89c8785eaef
Reviewed-on: https://go-review.googlesource.com/86475
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hiroshi Ioka <hirochachacha@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agocmd/go: check for another GCC error message
Ian Lance Taylor [Wed, 10 Jan 2018 14:28:59 +0000 (06:28 -0800)]
cmd/go: check for another GCC error message

GCC always recognizes the -fsplit-stack option, but then tests whether
it is supported by the selected target. If not, it reports
    cc1: error: ‘-fsplit-stack’ is not supported by this compiler configuration
Check for that error message when deciding whether a compiler option works.

Change-Id: I2eef8d550bbecba3a087869df2c7351280c77290
Reviewed-on: https://go-review.googlesource.com/87136
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agocmd/go: limit test input file change detection to local GOROOT/GOPATH tree
Russ Cox [Tue, 9 Jan 2018 20:16:29 +0000 (15:16 -0500)]
cmd/go: limit test input file change detection to local GOROOT/GOPATH tree

We've had a series of problems with tests unexpectedly (and innocently)
looking at system files that appear to (but don't) change in meaningful ways,
like /dev/null on OS X having a modification time set to the current time.

Cut all these off by only applying file change detection to the local package
root: the GOROOT or specific sub-GOPATH in which the package being tested
is found.

(This means that if you test reads /tmp/x and you change /tmp/x, the cached
result will still be used. Don't do that, or else use -count=1.)

Fixes #23390.

Change-Id: I30b6dd194835deb645a040aea5e6e4f68af09edb
Reviewed-on: https://go-review.googlesource.com/87015
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agogo/importer,os/exec: use testenv.GoToolPath
Daniel Martí [Wed, 10 Jan 2018 17:01:31 +0000 (17:01 +0000)]
go/importer,os/exec: use testenv.GoToolPath

These were the last two occurences of exec.Command("go", ...) in all of
std cmd. Checked with:

gogrep '$(f is(func))("go", $*_)' std cmd

Also changed lp_windows_test to use a test package name to avoid a
circular dependency, since internal/testenv imports os/exec.

Change-Id: I9a18948600dfecc8507ad76172e219e78b791ffd
Reviewed-on: https://go-review.googlesource.com/87200
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoos/exec: skip TestContextCancel on the Windows XP builder
Brad Fitzpatrick [Wed, 10 Jan 2018 19:15:36 +0000 (19:15 +0000)]
os/exec: skip TestContextCancel on the Windows XP builder

Updates #17245

Change-Id: I3d7ea362809040fbbba4b33efd57bf2d27d4c390
Reviewed-on: https://go-review.googlesource.com/87257
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agodoc/go1.10: document that Go 1.11 will remove Windows XP support
Russ Cox [Wed, 10 Jan 2018 16:18:59 +0000 (11:18 -0500)]
doc/go1.10: document that Go 1.11 will remove Windows XP support

Fixes #23380.

Change-Id: Ia9a086eada21b5561f110833afcf93e542a04407
Reviewed-on: https://go-review.googlesource.com/87175
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agogo/internal/gccgoimporter: parse optional escape info in export data
Robert Griesemer [Tue, 9 Jan 2018 18:28:29 +0000 (10:28 -0800)]
go/internal/gccgoimporter: parse optional escape info in export data

Fixes #23324.

Change-Id: Ie2383bad35f0bcc1344a8a1683be08d5fd0eea96
Reviewed-on: https://go-review.googlesource.com/86977
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/compile: workaround for inconsistent receiver param srcpos
Than McIntosh [Wed, 10 Jan 2018 02:20:10 +0000 (21:20 -0500)]
cmd/compile: workaround for inconsistent receiver param srcpos

Given an inlinable method M in package P:

   func (r *MyStruct) M(...) {

When M is compiled within its home package, the source position that
the compiler records for 'r' (receiver parameter variable) is
accurate, whereas if M is built as part of the compilation of some
other package (body read from export data), the declaration line
assigned to 'r' will be the line number of the 'import' directive, not
the source line from M's source file.

This inconsistency can cause differences in the size of abstract
parameter DIEs (due to variable-length encoding), which can then in
turn result in bad abstract origin offsets, which in turn triggers
build failures on iOS (dsymutil crashes when it encounters an
incorrect abstract origin reference).

Work around the problem by removing the "declaration line number"
attribute within the abstract parameter abbreviation table entry. The
decl line attribute doesn't contribute a whole lot to the debugging
experience, and it gets rid of the inconsistencies that trigger the
dsymutil crashes.

Updates #23374.

Change-Id: I0fdc8e19a48db0ccd938ceadf85103936f89ce9f
Reviewed-on: https://go-review.googlesource.com/87055
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
6 years agohtml/template: check for duplicates when inserting escapers
Samuel Tan [Thu, 14 Dec 2017 06:38:18 +0000 (22:38 -0800)]
html/template: check for duplicates when inserting escapers

Ensure that we do not insert any escapers into pipelines that
already contain an equivalent escaper. This prevents overescaping
from occuring even when an aliased parse tree that has already
been escaped is escaped again.

Fixes #21844

Change-Id: Ic00d5e01c97ef09a4e49407009cf71b0d07f5c0e
Reviewed-on: https://go-review.googlesource.com/83920
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agodoc/go1.10: fix typo of "preserves"
kim yongbin [Wed, 10 Jan 2018 16:49:45 +0000 (01:49 +0900)]
doc/go1.10: fix typo of "preserves"

Change-Id: Ib5f5d20200284850c14c2431687bc102696ef8ae
Reviewed-on: https://go-review.googlesource.com/87215
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go: run the real test binary if the test link was cached
Ian Lance Taylor [Fri, 15 Dec 2017 20:38:59 +0000 (12:38 -0800)]
cmd/go: run the real test binary if the test link was cached

Fixes #23150

Change-Id: Ia82c2d482a8dc53cabb3f173e4301fee66288821
Reviewed-on: https://go-review.googlesource.com/84376
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agonet/url: reject invalid userinfo values when parsing URLs
Brad Fitzpatrick [Tue, 9 Jan 2018 21:33:54 +0000 (21:33 +0000)]
net/url: reject invalid userinfo values when parsing URLs

Fixes #23392

Change-Id: I5822b082b14d886b9c3b5ad7beebb2c01a77851b
Reviewed-on: https://go-review.googlesource.com/87038
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoall: use Fatalf instead of Fatal if format is given
Kunpei Sakai [Tue, 9 Jan 2018 11:34:33 +0000 (20:34 +0900)]
all: use Fatalf instead of Fatal if format is given

Change-Id: I30e9b938bb19ed4e674c3ea4a1cd389b9c4f0b88
Reviewed-on: https://go-review.googlesource.com/86875
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agodoc/go1.10: fix more TODOs
Russ Cox [Tue, 9 Jan 2018 21:45:27 +0000 (16:45 -0500)]
doc/go1.10: fix more TODOs

Change-Id: I7be69a543841343a6ccbb335c7277009528fa0da
Reviewed-on: https://go-review.googlesource.com/87024
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoos: fix grammar nit
Russ Cox [Tue, 9 Jan 2018 20:49:40 +0000 (15:49 -0500)]
os: fix grammar nit

There should not be a comma before "and" in the original text,
because what follows is not a complete sentence. Rewrite.

Change-Id: Ie99f204cc87e911fb46149e2eb65e132fa1eb63a
Reviewed-on: https://go-review.googlesource.com/87020
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agospec: use consistent quoting style in prose
Robert Griesemer [Tue, 9 Jan 2018 20:42:28 +0000 (12:42 -0800)]
spec: use consistent quoting style in prose

Fixes #23389.

Change-Id: Id6e86eebe44809db12a0e14014c474bf4fbf5108
Reviewed-on: https://go-review.googlesource.com/87035
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: fix path for go tool in test
Keith Randall [Tue, 9 Jan 2018 21:23:13 +0000 (13:23 -0800)]
cmd/compile: fix path for go tool in test

Fixes #23326

Change-Id: I6abc353ab004aadc6a4cbefbff3198f848640d7f
Reviewed-on: https://go-review.googlesource.com/87036
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agostrings: prevent copyCheck from forcing Builder to escape and allocate
Brad Fitzpatrick [Tue, 9 Jan 2018 18:08:43 +0000 (18:08 +0000)]
strings: prevent copyCheck from forcing Builder to escape and allocate

All credit and blame goes to Ian for this suggestion, copied from the
runtime.

Fixes #23382
Updates #7921

Change-Id: I3d5a9ee4ab730c87e0f3feff3e7fceff9bcf9e18
Reviewed-on: https://go-review.googlesource.com/86976
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoreflect: fix doc nit
Russ Cox [Tue, 9 Jan 2018 20:52:01 +0000 (15:52 -0500)]
reflect: fix doc nit

Type values being comparable implies that Type is a valid map key type.
As previously written, they sound unrelated.

Change-Id: I8e2235275d62898bfb47de850e8257b51ab5cbd6
Reviewed-on: https://go-review.googlesource.com/87021
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: remove interior <code> spaces in debugging, diagnostics docs
Russ Cox [Tue, 9 Jan 2018 20:32:22 +0000 (15:32 -0500)]
doc: remove interior <code> spaces in debugging, diagnostics docs

Change-Id: I20de6207d386635025dbb603c57219218e9a9af5
Reviewed-on: https://go-review.googlesource.com/87019
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/debugging_with_gdb: soften text about disabling optimizations
Russ Cox [Tue, 9 Jan 2018 20:31:45 +0000 (15:31 -0500)]
doc/debugging_with_gdb: soften text about disabling optimizations

Don't suggest that it's always necessary to disable optimizations.
(The text can be misread that way, even if it's not what was meant.)

Change-Id: I9a2dff6a75ce4a3f9210cdf4f5bad6aaaeae9b29
Reviewed-on: https://go-review.googlesource.com/87018
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: s/tool chain/toolchain/
Russ Cox [Tue, 9 Jan 2018 20:26:21 +0000 (15:26 -0500)]
doc: s/tool chain/toolchain/

We were not being consistent.
Standardize on toolchain.

Change-Id: Id0e756b5214ce4a1341f733634ed95263f03a61c
Reviewed-on: https://go-review.googlesource.com/87017
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: adjust import config debugging flag
Russ Cox [Tue, 9 Jan 2018 19:49:08 +0000 (14:49 -0500)]
cmd/go: adjust import config debugging flag

Change-Id: I3afaefc154f9ccfac353cedac7aefcfb70afe265
Reviewed-on: https://go-review.googlesource.com/86996
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/link: set runtime.GOROOT default during link
Russ Cox [Mon, 8 Jan 2018 16:59:29 +0000 (11:59 -0500)]
cmd/link: set runtime.GOROOT default during link

Suppose you build the Go toolchain in directory A,
move the whole thing to directory B, and then use
it from B to build a new program hello.exe, and then
run hello.exe, and hello.exe crashes with a stack
trace into the standard library.

Long ago, you'd have seen hello.exe print file names
in the A directory tree, even though the files had moved
to the B directory tree. About two years ago we changed
the compiler to write down these files with the name
"$GOROOT" (that literal string) instead of A, so that the
final link from B could replace "$GOROOT" with B,
so that hello.exe's crash would show the correct source
file paths in the stack trace. (golang.org/cl/18200)

Now suppose that you do the same thing but hello.exe
doesn't crash: it prints fmt.Println(runtime.GOROOT()).
And you run hello.exe after clearing $GOROOT from the
environment.

Long ago, you'd have seen hello.exe print A instead of B.
Before this CL, you'd still see hello.exe print A instead of B.
This case is the one instance where a moved toolchain
still divulges its origin. Not anymore. After this CL, hello.exe
will print B, because the linker sets runtime/internal/sys.DefaultGoroot
with the effective GOROOT from link time.
This makes the default result of runtime.GOROOT once again
match the file names recorded in the binary, after two years
of divergence.

With that cleared up, we can reintroduce GOROOT into the
link action ID and also reenable TestExecutableGOROOT/RelocatedExe.

When $GOROOT_FINAL is set during link, it is used
in preference to $GOROOT, as always, but it was easier
to explain the behavior above without introducing that
complication.

Fixes #22155.
Fixes #20284.
Fixes #22475.

Change-Id: Ifdaeb77fd4678fdb337cf59ee25b2cd873ec1016
Reviewed-on: https://go-review.googlesource.com/86835
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/link: apply -X options after loading symbols
Russ Cox [Tue, 9 Jan 2018 15:10:46 +0000 (10:10 -0500)]
cmd/link: apply -X options after loading symbols

The linker has been applying -X options before loading symbols,
meaning that when it sees -X y=z it creates a symbol named y
and initializes its string data to z. The symbol named y is marked
"DUPOK" so that when the actual packages are loaded, no error is
emitted when the real y is seen. The predefined y's data is used
instead of whatever the real y says.

If we define -X y=z and we never load y, then the predefined symbol
is dropped during dead code elimination, but not in shared library
builds. Shared library builds must include all symbols, so we have to
be more careful about not defining symbols that wouldn't have
appeared anyway.

To be more careful, save the -X settings until after all the symbols
are loaded from the packages, and then apply the string changes
to whatever symbols are known (but ignore the ones that were not
loaded at all). This ends up being simpler anyway, since it doesn't
depend on DUPOK magic.

Makes CL 86835 safe.

Fixes #23273.

Change-Id: Ib4c9b2d5eafa97c5a8114401dbec0134c76be54f
Reviewed-on: https://go-review.googlesource.com/86915
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoRevert "html/template: prevent aliasing of parse Trees via AddParseTree"
Samuel Tan [Thu, 14 Dec 2017 06:38:00 +0000 (22:38 -0800)]
Revert "html/template: prevent aliasing of parse Trees via AddParseTree"

This reverts commit cd0a5f08293e1bf1fac41ae6438d495318cd52fb, which
unnecessarily restricts the use of AddParseTree.

Change-Id: I1155214a20ba08981d604404e79fff54874fd8e4
Reviewed-on: https://go-review.googlesource.com/83919
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/test2json: emit Benchmark name output early
Russ Cox [Mon, 8 Jan 2018 17:11:00 +0000 (12:11 -0500)]
cmd/test2json: emit Benchmark name output early

When benchmarks run, they print lines like:

  BenchmarkGenericNoMatch-8   3000000 385 ns/op

The first field, padded by spaces and followed by a tab,
is printed when the benchmark begins running.
The rest of the line is printed when the benchmark ends.
Tools and people can watch the timing of these prints
to see which benchmark is running.

To allow tools consuming json output to continue to be
able to see which benchmark is running, this CL adds a
special case to the usual "line at a time" behavior to flush
the benchmark name if it is observed separately from the
rest of the line.

Fixes #23352.

Change-Id: I7b6410698d78034eec18745d7f57b7d8e9575dbb
Reviewed-on: https://go-review.googlesource.com/86695
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocontainer/list: document nil values more
Brad Fitzpatrick [Mon, 8 Jan 2018 16:01:52 +0000 (16:01 +0000)]
container/list: document nil values more

Fixes #23372

Change-Id: Ie99fb4d84cb49efa66c0ff480d2656c33ef11e6d
Reviewed-on: https://go-review.googlesource.com/86676
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agoA+C: update late Go 1.10 contributors
Brad Fitzpatrick [Sat, 6 Jan 2018 03:03:58 +0000 (03:03 +0000)]
A+C: update late Go 1.10 contributors

Add Brad Burch (individual CLA)
Add Charles Fenwick Elliott (individual CLA)
Add Geoff Berry (corporate CLA for Qualcomm Data Center, Inc.)
Add Igor Vashyst (individual CLA)
Add Jiulong Wang (individual CLA)
Add Junya Hayashi (individual CLA)
Add Matthijs Kooijman (individual CLA)
Add Paul PISCUC (individual CLA)
Add Steve Gilbert (individual CLA)
Add Tad Fisher (individual CLA)
Add Yukihiro Nishinaka (individual CLA)

Updates #12042

Change-Id: Ib7a3c7a4d38d15530c2ea42fe8d359ae10c9a19e
Reviewed-on: https://go-review.googlesource.com/86478
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocrypto/x509: update iOS root certs.
Giovanni Bajo [Mon, 13 Nov 2017 00:54:08 +0000 (01:54 +0100)]
crypto/x509: update iOS root certs.

Apple changed the format of its support page, so we need to
restructure the HTML parser. The HTML table is now parsed using
regular expressions, and certificates are then found in macOS
trust store by their fingerprint.

Fixes #22181

Change-Id: I29e7a40d37770bb005d728f1832299c528691f7e
Reviewed-on: https://go-review.googlesource.com/77252
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
6 years agodoc/go1.10: remove ReverseProxy TODO
Brad Fitzpatrick [Sat, 6 Jan 2018 01:16:09 +0000 (01:16 +0000)]
doc/go1.10: remove ReverseProxy TODO

No longer needs to be done.

Updates #23009
Updates #21255

Change-Id: I78e9e29a923dc03dea89ff3a5bf60f2e0bd0c0aa
Reviewed-on: https://go-review.googlesource.com/86476
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoRevert "net/http/httputil: allow ReverseProxy to call ModifyResponse on failed requests"
Brad Fitzpatrick [Fri, 5 Jan 2018 21:35:51 +0000 (21:35 +0000)]
Revert "net/http/httputil: allow ReverseProxy to call ModifyResponse on failed requests"

This reverts commit https://golang.org/cl/54030

Reason for revert: to not paint ourselves into a corner.
See https://github.com/golang/go/issues/23009

Fixes #23009
Updates #21255

Change-Id: I68caab078839b9d2bf645a7bbed8405a5a30cd22
Reviewed-on: https://go-review.googlesource.com/86435
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agonet/http: document cloning of Server.TLSConfig
Brad Fitzpatrick [Fri, 5 Jan 2018 21:31:57 +0000 (21:31 +0000)]
net/http: document cloning of Server.TLSConfig

Updates #22018

Change-Id: I8a85324e9d53dd4d279ed05cdb93f50d55cf767b
Reviewed-on: https://go-review.googlesource.com/86415
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: add support for build IDs with gccgo
Ian Lance Taylor [Wed, 27 Dec 2017 22:07:01 +0000 (14:07 -0800)]
cmd/go: add support for build IDs with gccgo

This just adds support on ELF systems, which is OK for now since that
is all that gccgo works on.

For the archive file generated by the compiler we add a new file
_buildid.o that has a section .go.buildid containing the build ID.
Using a new file lets us set the SHF_EXCLUDE bit in the section header,
so the linker will discard the section. It would be nicer to use
`objcopy --add-section`, but objcopy doesn't support setting the
SHF_EXCLUDE bit.

For an executable we just use an ordinary GNU build ID. Doing this
required modifying cmd/internal/buildid to look for a GNU build ID,
and use it if there is no other Go-specific note.

This CL fixes a minor bug in gccgoTOolchain.link: it was using .Target
instead of .built, so it failed for a cached file.

This CL fixes a bug reading note segments: the notes are aligned as
reported by the PT_NOTE's alignment field.

Updates #22472

Change-Id: I4d9e9978ef060bafc5b9574d9af16d97c13f3102
Reviewed-on: https://go-review.googlesource.com/85555
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/test2json: fix processing of --- BENCH: output
Russ Cox [Fri, 5 Jan 2018 21:06:47 +0000 (16:06 -0500)]
cmd/test2json: fix processing of --- BENCH: output

If a benchmark calls b.Log without failing (without b.Error/b.Fatal/b.FailNow)
then that turns into output very much like a test passing,
except it says BENCH instead of PASS.
Benchmarks failing say FAIL just like tests failing.

Fixes #23346.

Change-Id: Ib188e695952da78057ab4a13f90d49937aa3c232
Reviewed-on: https://go-review.googlesource.com/86396
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/debugging_with_gdb: mention delve as an alternative.
Hana Kim [Tue, 19 Dec 2017 20:21:05 +0000 (15:21 -0500)]
doc/debugging_with_gdb: mention delve as an alternative.

Fixes #23108

Change-Id: I9b3d0f0c399c0b4cb488adaf3c002bc55d5d21d9
Reviewed-on: https://go-review.googlesource.com/84795
Reviewed-by: Heschi Kreinick <heschi@google.com>
6 years agogo/constant: make string addition compute actual string lazily
Russ Cox [Fri, 5 Jan 2018 18:20:08 +0000 (13:20 -0500)]
go/constant: make string addition compute actual string lazily

It is natural for tools to take a large string concatenation like

"1" + "1" + "1" + ... + "1"

and translate that into a sequence of go/constant calls:

x := constant.MakeString("1")
x = constant.BinaryOp(x, token.ADD, constant.MakeString("1"))
x = constant.BinaryOp(x, token.ADD, constant.MakeString("1"))
x = constant.BinaryOp(x, token.ADD, constant.MakeString("1"))
x = constant.BinaryOp(x, token.ADD, constant.MakeString("1"))
...

If the underlying representation of a string constant is a Go string,
then this leads to O(N²) memory for the concatenation of N strings,
allocating memory for "1", "11", "111", "1111", and so on.
This makes go/types and in particular cmd/vet run out of memory
(or at least use far too much) on machine-generated string concatenations,
such as those generated by go-bindata.

This CL allows code like the above to operate efficiently, by delaying
the evaluation of the actual string constant value until it is needed.
Now the representation of a string constant is either a string or an
explicit addition expression. The addition expression is turned into
a string the first time it is requested and then cached for future use.
This slows down the use of single strings, but analyses are likely not
dominated by that use anyway. It speeds up string concatenations,
especially large ones, significantly.

On my Mac running 32-bit code:

name               old time/op    new time/op    delta
StringAdd/1-8         160ns ± 2%     183ns ± 1%  +13.98%  (p=0.000 n=10+10)
StringAdd/4-8         650ns ± 1%     927ns ± 4%  +42.73%  (p=0.000 n=10+10)
StringAdd/16-8       3.93µs ± 1%    2.78µs ± 2%  -29.12%  (p=0.000 n=8+9)
StringAdd/64-8       37.3µs ± 9%    10.1µs ± 5%  -73.06%  (p=0.000 n=10+10)
StringAdd/256-8       513µs ± 5%      38µs ± 1%  -92.63%  (p=0.000 n=10+10)
StringAdd/1024-8     5.67ms ± 4%    0.14ms ± 2%  -97.45%  (p=0.000 n=8+10)
StringAdd/4096-8     77.1ms ± 9%     0.7ms ± 2%  -99.10%  (p=0.000 n=10+9)
StringAdd/16384-8     1.33s ± 7%     0.00s ±10%  -99.64%  (p=0.000 n=10+10)
StringAdd/65536-8     21.5s ± 4%      0.0s ± 8%  -99.89%  (p=0.000 n=10+10)

name               old alloc/op   new alloc/op   delta
StringAdd/1-8          232B ± 0%      256B ± 0%  +10.34%  (p=0.000 n=10+10)
StringAdd/4-8        1.20kB ± 0%    1.24kB ± 0%   +3.33%  (p=0.000 n=10+10)
StringAdd/16-8       14.7kB ± 0%     4.6kB ± 0%  -68.87%  (p=0.000 n=10+10)
StringAdd/64-8        223kB ± 0%      16kB ± 0%  -92.66%  (p=0.000 n=10+10)
StringAdd/256-8      3.48MB ± 0%    0.07MB ± 0%  -98.07%  (p=0.000 n=10+10)
StringAdd/1024-8     55.7MB ± 0%     0.3MB ± 0%  -99.53%  (p=0.000 n=10+10)
StringAdd/4096-8      855MB ± 0%       1MB ± 0%  -99.88%  (p=0.000 n=10+10)
StringAdd/16384-8    13.5GB ± 0%     0.0GB ± 0%  -99.97%  (p=0.000 n=9+10)
StringAdd/65536-8     215GB ± 0%       0GB ± 0%  -99.99%  (p=0.000 n=10+10)

name               old allocs/op  new allocs/op  delta
StringAdd/1-8          3.00 ± 0%      3.00 ± 0%     ~     (all equal)
StringAdd/4-8          9.00 ± 0%     11.00 ± 0%  +22.22%  (p=0.000 n=10+10)
StringAdd/16-8         33.0 ± 0%      25.0 ± 0%  -24.24%  (p=0.000 n=10+10)
StringAdd/64-8          129 ± 0%        75 ± 0%  -41.86%  (p=0.000 n=10+10)
StringAdd/256-8         513 ± 0%       269 ± 0%  -47.56%  (p=0.000 n=10+10)
StringAdd/1024-8      2.05k ± 0%     1.04k ± 0%  -49.29%  (p=0.000 n=10+10)
StringAdd/4096-8      8.19k ± 0%     4.12k ± 0%  -49.77%  (p=0.000 n=10+10)
StringAdd/16384-8     32.8k ± 0%     16.4k ± 0%  -49.97%  (p=0.000 n=9+10)
StringAdd/65536-8      131k ± 0%       66k ± 0%  -50.11%  (p=0.000 n=10+10)

https://perf.golang.org/search?q=upload:20180105.2

Fixes #23348 (originally reported as cmd/vet failures in comments on #23222).

This makes constant.Values of Kind String no longer meaningful for ==, which
required fixes in go/types. While there, also fix go/types handling of constant.Values
of Kind Int (for uint64), Float, and Complex.

Change-Id: I80867bc9c4232c5c9b213443ff16645434a68b36
Reviewed-on: https://go-review.googlesource.com/86395
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocmd/go: skip long tests in -short mode
Russ Cox [Thu, 4 Jan 2018 22:22:29 +0000 (17:22 -0500)]
cmd/go: skip long tests in -short mode

I marked every test that takes more than 0.5 seconds on my machine
as something to run only when not in -short mode, or in -short mode
on the beefy linux/amd64, windows/amd64, and darwin/amd64 builders.

I also shortened a few needlessly-expensive tests where possible.

Cuts the time for go test -short cmd/go from 45s to 15s on my machine.
Should help even more on some of our builders and slower user machines.

Fixes #23287.

Change-Id: I0e36003ef947b0ebe4224a1373731f9fa9216843
Reviewed-on: https://go-review.googlesource.com/86252
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agonet/http: document internal error errServerClosedIdle more
Brad Fitzpatrick [Fri, 5 Jan 2018 17:03:51 +0000 (17:03 +0000)]
net/http: document internal error errServerClosedIdle more

Updates #19943

Change-Id: Iea249be51a7af3264bee9ee2b28dbd91043275fc
Reviewed-on: https://go-review.googlesource.com/86375
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agonet/http: don't validate WriteHeader code if header's already been sent
Brad Fitzpatrick [Thu, 4 Jan 2018 22:26:20 +0000 (22:26 +0000)]
net/http: don't validate WriteHeader code if header's already been sent

Also vendors x/net/http git rev 42fe2e1c for:

    http2: don't check WriteHeader status if we've already sent the header
    https://golang.org/cl/86255

Fixes #23010

Change-Id: I4f3dd63acb52d5a34a0350aaf847a7a376d6968f
Reviewed-on: https://go-review.googlesource.com/86275
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agonet/http: document CONNECT more
Brad Fitzpatrick [Thu, 4 Jan 2018 23:36:16 +0000 (23:36 +0000)]
net/http: document CONNECT more

Fixes #22554

Change-Id: I624f2883489a46d7162c11f489c2f0a0ec5a836f
Reviewed-on: https://go-review.googlesource.com/86277
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agonet/http: soften wording around when the Transport reuses connections
Brad Fitzpatrick [Thu, 4 Jan 2018 23:06:31 +0000 (23:06 +0000)]
net/http: soften wording around when the Transport reuses connections

The docs were too specific. Make it vaguer. There are conditions for
which the Transport will try to reuse a connection anyway, even if the
Response Body isn't read to EOF or closed, but we don't need to get
into all the details in the docs.

Fixes #22954

Change-Id: I3b8ae32aeb1a61b396d0026e129552afbfecceec
Reviewed-on: https://go-review.googlesource.com/86276
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: fix build failure in -x test
Russ Cox [Thu, 4 Jan 2018 20:09:21 +0000 (15:09 -0500)]
cmd/go: fix build failure in -x test

CL 84735 strengthened the -x test to make sure commands succeed,
using set -e, but the gcc flag tests can fail. Change them to say || true.

Fixes #23337.

Change-Id: I01e4017cb36ceb147b56935c2636de52ce7bdfdb
Reviewed-on: https://go-review.googlesource.com/86239
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocrypto/tls: optional "certificate_status" with OCSP
Brad Burch [Thu, 4 Jan 2018 06:42:10 +0000 (00:42 -0600)]
crypto/tls: optional "certificate_status" with OCSP

Follows the wording in RFC4366 more precisely which allows a server
to optionally return a "certificate_status" when responding to a
client hello containing "status_request" extension.

fixes #8549

Change-Id: Ib02dc9f972da185b25554568fe6f8bc411d9c0b7
Reviewed-on: https://go-review.googlesource.com/86115
Reviewed-by: Adam Langley <agl@golang.org>
6 years agomath/rand: typo fixed in documentation of seedPos
Paul PISCUC [Thu, 4 Jan 2018 20:25:04 +0000 (21:25 +0100)]
math/rand: typo fixed in documentation of seedPos

In the comment of seedPost, the word: condiiton was changed to: condition

Change-Id: I8967cc0e9f5d37776bada96cc1443c8bf46e1117
Reviewed-on: https://go-review.googlesource.com/86156
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agospec: consistently use "element" rather than "value" for map entry values
Robert Griesemer [Wed, 3 Jan 2018 18:33:11 +0000 (10:33 -0800)]
spec: consistently use "element" rather than "value" for map entry values

The spec refers to a map's key and element types; thus the respective
values are "keys" and "elements". Also, a map value is the value of
the entire map.

Similar fix for channels, where appropriate.

Fixes #23254.

Change-Id: I6f03ea6d86586c7b0b3e84f0c2e9446b8109fa53
Reviewed-on: https://go-review.googlesource.com/85999
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agosync: document when and when not to use Map
Russ Cox [Wed, 13 Dec 2017 16:49:26 +0000 (11:49 -0500)]
sync: document when and when not to use Map

Fixes #21587.

Change-Id: I47eb181d65da67a3b530c7f8acac9c0c619ea474
Reviewed-on: https://go-review.googlesource.com/83796
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/test2json: fix test log output containing test output
Russ Cox [Thu, 4 Jan 2018 18:25:31 +0000 (13:25 -0500)]
cmd/test2json: fix test log output containing test output

If test case framing appears in ordinary test output,
then test2json can get confused. If the fake framing is being
saved with t.Logf/t.Errorf/etc then we can already
distinguish it from real framing, and the code did.
It just forgot to write that framing as output (1-line fix).

If the fake framing is being generated by printing directly
to stdout/stderr, then test2json will simply get confused.
There's not a lot to do at that point (maybe it's even a feature).

Fixes #23036.

Change-Id: I29449c7ace304172b89d8babe23de507c0500455
Reviewed-on: https://go-review.googlesource.com/86238
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: fix caching of test -json outputs
Russ Cox [Thu, 14 Dec 2017 19:53:40 +0000 (14:53 -0500)]
cmd/go: fix caching of test -json outputs

go test -json was inadvertently disabling caching. Fix that.

Fixes #22984.

Change-Id: Ic933a8c8ac00ce8253e934766954b1ccc6ac0cec
Reviewed-on: https://go-review.googlesource.com/84075
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: fix coverage rebuild corner case
Russ Cox [Thu, 4 Jan 2018 18:07:44 +0000 (13:07 -0500)]
cmd/go: fix coverage rebuild corner case

If you have a package p1 with an xtest (package p1_test)
that imports p2, where p2 itself imports p1, then when
trying to do coverage for p1 we need to make sure to
recompile p2. The problem was that the overall package
import graph looked like:

    main -> p1_test -> p2 -> p1

Since we were recompiling p1 with coverage, we correctly
figured out that because p2 depends on a package being
recompiled due to coverage, p2 also needs to be split (forked) to
insert the dependency on the modified p1. But then we used
the same logic to split p1_test and main, with the effect that
the changes to p2 and p1_test and main were lost, since the
caller was still holding on to the original main, not the split version.

Change the code to treat main and p1_test as "already split"
and just update them in place.

Fixes #23314.

Change-Id: If7edeca6e39cdaeb5b9380d00b0c7d8c5891f086
Reviewed-on: https://go-review.googlesource.com/86237
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: fix compile -p flag for building test of main package
Russ Cox [Thu, 4 Jan 2018 17:27:32 +0000 (12:27 -0500)]
cmd/go: fix compile -p flag for building test of main package

Fixes #23180.

Change-Id: I52404ee98dcc60b96972d4242c13db0ec4340d0d
Reviewed-on: https://go-review.googlesource.com/86235
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>