]> Cypherpunks repositories - gostls13.git/log
gostls13.git
6 years agocmd/go: diagnose 'go mod' in GOPATH/src better
Russ Cox [Wed, 18 Jul 2018 19:05:17 +0000 (15:05 -0400)]
cmd/go: diagnose 'go mod' in GOPATH/src better

People are (understandably) confused by creating go.mod files in GOPATH/src
and then having the go command not use modules in those directories.
We can't change that behavior (or we'll break non-module users of GOPATH)
but we can force 'go mod' (including 'go mod -init') to fail loudly in that case.

If this is not enough, the next step would be to print a warning every time
the go command is run in a GOPATH/src directory with a go.mod but
module mode hasn't triggered. But that will annoy all the non-module users.
Hopefully anyone confused will eventually run a 'go mod' command of
some kind, which will fail loudly.

Fixes #26365.

Change-Id: I8c5fe987fbc3f8d2eceb1138e6862a391ade150c
Reviewed-on: https://go-review.googlesource.com/124708
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: document $GOPROXY, other module adjustments
Russ Cox [Wed, 18 Jul 2018 18:40:20 +0000 (14:40 -0400)]
cmd/go: document $GOPROXY, other module adjustments

Also document module use of GOPATH including GOPATH/src/mod
and GOPATH/bin (unless GOBIN is set).

Fixes #26399.
Fixes #26406.

Change-Id: I7be8eaf110f4fa6fc76ea4cd39aea3dd8addf0b0
Reviewed-on: https://go-review.googlesource.com/124707
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go/internal/modget: fix get pkg@none
Russ Cox [Wed, 18 Jul 2018 20:18:29 +0000 (16:18 -0400)]
cmd/go/internal/modget: fix get pkg@none

Now pkg@none actually removes the pkg instead of dying.

For #26342.

Change-Id: I9df7281ed8fd24480109b36f33a563f92e279244
Reviewed-on: https://go-review.googlesource.com/124796
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: convert final module tests to scripts
Russ Cox [Wed, 18 Jul 2018 17:23:17 +0000 (13:23 -0400)]
cmd/go: convert final module tests to scripts

Change-Id: Iba68b3aaf4a132bd4ca44edf4912a46549d2ef8f
Reviewed-on: https://go-review.googlesource.com/124700
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go/internal/modfetch: move to new pseudo-version design
Russ Cox [Tue, 17 Jul 2018 14:16:38 +0000 (10:16 -0400)]
cmd/go/internal/modfetch: move to new pseudo-version design

The original pseudo-version design used versions of the form

v0.0.0-yyyymmddhhmmss-abcdef123456

These were intentionally chosen to be valid semantic versions
that sort below any explicitly-chosen semantic version (even v0.0.0),
so that they could be used before anything was tagged but after
that would essentially only be useful in replace statements
(because the max operation during MVS would always prefer
a tagged version).

Then we changed the go command to accept hashes on the
command line, so that you can say

go get github.com/my/proj@abcdef

and it will download and use v0.0.0-yyyymmddhhmmss-abcdef123456.

If you were using v1.10.1 before and this commit is just little bit
newer than that commit, calling it v0.0.0-xxx is confusing but
also harmful: the go command sees the change from v1.10.1 to
the v0.0.0 pseudoversion as a downgrade, and it downgrades other
modules in the build. In particular if some other module has
a requirement of github.com/my/proj v1.9.0 (or later), the
pseudo-version appears to be before that, so go get would
downgrade that module too. It might even remove it entirely,
if every available version needs a post-v0.0.0 version of my/proj.

This CL introduces new pseudo-version forms that can be used
to slot in after the most recent explicit tag before the commit.
If the most recent tagged commit before abcdef is v1.10.1,
then now we will use

v1.10.2-0.yyyymmddhhmmss-abcdef123456

This has the right properties for downgrades and the like,
since it is after v1.10.1 but before almost any possible
successor, such as v1.10.2, v1.10.2-1, or v1.10.2-pre.

This CL also uses those pseudo-version forms as appropriate
when mapping a hash to a pseudo-version. This fixes the
downgrade problem.

Overall, this CL reflects our growing recognition of pseudo-versions
as being like "untagged prereleases".

Issue #26150 was about documenting best practices for how
to work around this kind of accidental downgrade problem
with additional steps. Now there are no additional steps:
the problem is avoided by default.

Fixes #26150.

Change-Id: I402feeccb93e8e937bafcaa26402d88572e9b14c
Reviewed-on: https://go-review.googlesource.com/124515
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go/internal/module: add new +incompatible version build annotation
Russ Cox [Mon, 16 Jul 2018 15:38:57 +0000 (11:38 -0400)]
cmd/go/internal/module: add new +incompatible version build annotation

Repos written before the introduction of semantic import versioning
introduced tags like v2.0.0, v3.0.0, and so on, expecting that
(1) the import path would remain unchanged, and perhaps also
(2) there would be at most one copy of the package in a build.

We've always accommodated these by mapping them into the
v0/v1 version range, so that if you ran

    go get k8s.io/client-go@v8.0.0

it would not complain about v8.x.x being a non-v1 version and
instead would map that version to a pseudo-version in go.mod:

    require k8s.io/client-go v0.0.0-20180628043050-7d04d0e2a0a1

The pseudo-version fails to capture two important facts: first,
that this really is the v8.0.0 tag, and second, that it should be
preferred over any earlier v1 tags.

A related problem is that running "go get k8s.io/client-go"
with no version will choose the latest v1 tag (v1.5.1), which
is obsolete.

This CL introduces a new version suffix +incompatible that
indicates that the tag should be considered an (incompatible)
extension of the v1 version sequence instead of part of its
own major version with its own versioned module path.
The requirement above can now be written:

    require k8s.io/client-go v8.0.0+incompatible

(The +metadata suffix is a standard part of semantic versioning,
and that suffix is ignored when comparing two versions for
precedence or equality. As part of canonicalizing versions
recorded in go.mod, the go command has always stripped all
such suffixes. It still strips nearly all: only +incompatible is
preserved now.)

In addition to recognizing the +incompatible, the code that
maps a commit hash to a version will use that form when
appropriate, so that

    go get k8s.io/client-go@7d04d0

will choose k8s.io/client-go@v8.0.0+incompatible.

Also, the code that computes the list of available versions from
a given source code repository also maps old tags to +incompatible
versions, for any tagged commit in which a go.mod file does not exist.
Therefore

    go list -m -versions k8s.io/client-go@latest

will show

    k8s.io/client-go v1.4.0 v1.5.0 v1.5.1 v2.0.0-alpha.0+incompatible ... v8.0.0+incompatible

and similarly

    go get k8s.io/client-go

will now choose v8.0.0+incompatible as the meaning of "latest tagged version".

The extraction of +incompatible versions from source code repos
depends on a codehost.Repo method ReadFileRevs, to do a bulk read
of multiple revisions of a file. That method is only implemented for git in this CL.
Future CLs will need to add support for that method to the other repository
implementations.

Documentation for this change is in CL 124515.

Fixes #26238.

Change-Id: I5bb1d7a46b5fffde34a3c0e6f8d19d9608188cea
Reviewed-on: https://go-review.googlesource.com/124384
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go: preserve %SYSTEMROOT% in TestScript on Windows
Russ Cox [Thu, 19 Jul 2018 13:31:55 +0000 (09:31 -0400)]
cmd/go: preserve %SYSTEMROOT% in TestScript on Windows

Windows networking doesn't work without this environment variable (#25210).

Re-enable TestScript on Windows, and fix two minor failures.

Fixes #26457.

Change-Id: Id9bea49dfb58403195c29c3d831a532ef0f9a233
Reviewed-on: https://go-review.googlesource.com/124858
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoruntime: don't create heap hints outside TSAN's supported heap
Austin Clements [Fri, 13 Jul 2018 21:29:39 +0000 (17:29 -0400)]
runtime: don't create heap hints outside TSAN's supported heap

TSAN for Go only supports heap address in the range [0x00c000000000,
0x00e000000000). However, we currently create heap hints of the form
0xXXc000000000 for XX between 0x00 and 0x7f. Even for XX=0x01, this
hint is outside TSAN's supported heap address range.

Fix this by creating a slightly different set of hints in race mode,
all of which fall inside TSAN's heap address range.

This should fix TestArenaCollision flakes. That test forces the
runtime to use later heap hints. Currently, this always results in
TSAN "failed to allocate" failures on Windows (which happens to have a
slightly more constrained TSAN layout than non-Windows). Most of the
time we don't notice these failures, but sometimes it crashes TSAN,
leading to a test failure.

Fixes #25698.

Change-Id: I8926cd61f0ee5ee00efa77b283f7b809c555be46
Reviewed-on: https://go-review.googlesource.com/123780
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
6 years agocmd/compile: add test for OPmodify ops clobbering flags
Keith Randall [Tue, 17 Jul 2018 22:07:26 +0000 (15:07 -0700)]
cmd/compile: add test for OPmodify ops clobbering flags

Code fix was in CL 122556.  This is a corresponding test case.

Fixes #26426

Change-Id: Ib8769f367aed8bead029da0a8d2ddccee1d1dccb
Reviewed-on: https://go-review.googlesource.com/124535
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: remove paragraph about text/template/parse
Daniel Martí [Thu, 19 Jul 2018 10:06:56 +0000 (11:06 +0100)]
doc: remove paragraph about text/template/parse

The backwards incompatible changes were undone in CL 120355, while still
preserving the additions needed for assignments in templates to work.

Change-Id: Ie76a798916ef36509c88e171a04bb2cf2a3d7e8e
Reviewed-on: https://go-review.googlesource.com/124917
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agocmd/compile: avoid compressed dwarf when testing for gdb on OSX
David Chase [Wed, 18 Jul 2018 15:23:56 +0000 (11:23 -0400)]
cmd/compile: avoid compressed dwarf when testing for gdb on OSX

Until we figure out how to deal with gdb on Darwin (doesn't
read compressed DWARF from binaries), avoid compressing
DWARF in that case so that the test will still yield meaningful
results.

This is also reported to be a problem for Windows.

Problem also exists for lldb, but this test doesn't check
lldb.

Updates #25925

Change-Id: I85c0e5db75f3329957290500626a3ac7f078f608
Reviewed-on: https://go-review.googlesource.com/124712
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
6 years agocmd/go: skip TestScript/mod_* on Windows
Russ Cox [Thu, 19 Jul 2018 05:37:21 +0000 (01:37 -0400)]
cmd/go: skip TestScript/mod_* on Windows

I don't know why it's failing.
Filed #26457.

Change-Id: I84833293a572c5a1a25135bd01cb88518fc7441e
Reviewed-on: https://go-review.googlesource.com/124857
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/internal/str: simplify HasPathPrefix by epsilon
Russ Cox [Wed, 18 Jul 2018 20:20:19 +0000 (16:20 -0400)]
cmd/go/internal/str: simplify HasPathPrefix by epsilon

Pointed out in CL 122396.
An empty prefix has already been handled above.

Change-Id: Ib94df0a9c8c0517f932b90126232111caa9ad289
Reviewed-on: https://go-review.googlesource.com/124797
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: convert still more module tests to scripts
Russ Cox [Wed, 18 Jul 2018 13:08:45 +0000 (09:08 -0400)]
cmd/go: convert still more module tests to scripts

Change-Id: I249bb848c9911948dbd84cd88ad043a61ed6ea6b
Reviewed-on: https://go-review.googlesource.com/124699
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: convert even more module tests to scripts
Russ Cox [Wed, 18 Jul 2018 03:46:12 +0000 (23:46 -0400)]
cmd/go: convert even more module tests to scripts

Change-Id: Iba185e00e9df2462e9089566053f6c64e24a6a92
Reviewed-on: https://go-review.googlesource.com/124698
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: convert more module tests to scripts
Russ Cox [Wed, 18 Jul 2018 02:59:51 +0000 (22:59 -0400)]
cmd/go: convert more module tests to scripts

Change-Id: I8a36fad061bdf9a19f40531511f3f5717db13b60
Reviewed-on: https://go-review.googlesource.com/124697
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: convert module tests to scripts
Russ Cox [Wed, 18 Jul 2018 02:35:10 +0000 (22:35 -0400)]
cmd/go: convert module tests to scripts

Change-Id: If0976d15027db795f1383ef709c49c838cbb6953
Reviewed-on: https://go-review.googlesource.com/124696
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agonet/http: deflake TestClientTimeoutKillsConn_AfterHeaders
Brad Fitzpatrick [Wed, 18 Jul 2018 21:37:56 +0000 (21:37 +0000)]
net/http: deflake TestClientTimeoutKillsConn_AfterHeaders

It was flaky on slower machines.

Per report at https://github.com/golang/go/issues/23399#issuecomment-405792381

Change-Id: I7cab02821f78b5ce02ea51089d7eb51723f9705f
Reviewed-on: https://go-review.googlesource.com/124835
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: update the Origins section of the FAQ
Rob Pike [Wed, 18 Jul 2018 05:10:04 +0000 (15:10 +1000)]
doc: update the Origins section of the FAQ

Completely replace the opener, which had become not only stale
but bad, expand the discussion of the gopher, and generally provide
prose more connected to the present than to the programming world
of 2007.

Fixes #26107

Change-Id: I5e72f0c81e71d1237fe142dc26114991329a6996
Reviewed-on: https://go-review.googlesource.com/124616
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: fill in final standard library TODOs in go1.11.html
Ian Lance Taylor [Wed, 18 Jul 2018 22:29:32 +0000 (15:29 -0700)]
doc: fill in final standard library TODOs in go1.11.html

Change-Id: Ic1ff580573711a6c91c1d5e3eb019a298a2fec49
Reviewed-on: https://go-review.googlesource.com/124837
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: update go1.11 release notes
Brad Fitzpatrick [Wed, 18 Jul 2018 21:57:36 +0000 (21:57 +0000)]
doc: update go1.11 release notes

Change-Id: I9008afdc8c38c440ea083a4f2bed0d2253e112f0
Reviewed-on: https://go-review.googlesource.com/124836
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: update go1.11 release notes
Andrew Bonventre [Wed, 18 Jul 2018 20:49:23 +0000 (16:49 -0400)]
doc: update go1.11 release notes

Change-Id: I3e2a19fe90334f0c1ed1593c7a9a3a458f15d8e8
Reviewed-on: https://go-review.googlesource.com/124799
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agodoc: update go1.11 release notes
Andrew Bonventre [Wed, 18 Jul 2018 20:44:07 +0000 (16:44 -0400)]
doc: update go1.11 release notes

Change-Id: Ib488a78802ad730e7c6b3618eab24c259f4bebd1
Reviewed-on: https://go-review.googlesource.com/124798
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agodoc/go1.11: add some links to text/scanner, remove parens
Brad Fitzpatrick [Wed, 18 Jul 2018 20:20:56 +0000 (20:20 +0000)]
doc/go1.11: add some links to text/scanner, remove parens

Change-Id: I30d2b4b94f26300f2cf7b4ecd328a4875d69db51
Reviewed-on: https://go-review.googlesource.com/124777
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/go1.11: update runtime/trace to use region instead of span
Hana (Hyang-Ah) Kim [Wed, 18 Jul 2018 20:26:13 +0000 (16:26 -0400)]
doc/go1.11: update runtime/trace to use region instead of span

The final API uses 'region' instead of 'span' from the proposal.

Change-Id: I305da891a360596fff89b10bc6de3090289b5396
Reviewed-on: https://go-review.googlesource.com/124815
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: add a couple of links to go1.11 release notes
Ian Lance Taylor [Wed, 18 Jul 2018 20:30:25 +0000 (13:30 -0700)]
doc: add a couple of links to go1.11 release notes

Change-Id: Ie4e81b88cc8035fddf9c074363a1b35bcae3d470
Reviewed-on: https://go-review.googlesource.com/124778
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: fix crash on invalid struct literal
Daniel Martí [Tue, 17 Jul 2018 13:38:52 +0000 (14:38 +0100)]
cmd/compile: fix crash on invalid struct literal

If one tries to use promoted fields in a struct literal, the compiler
errors correctly. However, if the embedded fields are of struct pointer
type, the field.Type.Sym.Name expression below panics.

This is because field.Type.Sym is nil in that case. We can simply use
field.Sym.Name in this piece of code though, as it only concerns
embedded fields, in which case what we are after is the field name.

Added a test mirroring fixedbugs/issue23609.go, but with pointer types.

Fixes #26416.

Change-Id: Ia46ce62995c9e1653f315accb99d592aff2f285e
Reviewed-on: https://go-review.googlesource.com/124395
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agodoc: update go1.11 release notes
Ian Lance Taylor [Wed, 18 Jul 2018 20:19:04 +0000 (13:19 -0700)]
doc: update go1.11 release notes

Change-Id: I806d411c075cdc66322112b6ee5e50f58462bc6b
Reviewed-on: https://go-review.googlesource.com/124776
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc/go1.11: shorten, tidy, and promote user annotation API
Austin Clements [Wed, 18 Jul 2018 20:09:06 +0000 (16:09 -0400)]
doc/go1.11: shorten, tidy, and promote user annotation API

Text based on CL 124655.

Change-Id: I7c4866ce829cb28a4c60cd8ced3ef99047a38c54
Reviewed-on: https://go-review.googlesource.com/124711
Reviewed-by: Austin Clements <austin@google.com>
6 years agofilepath: updates doc to give case where WalkFunc info arg may be nil
Jack [Wed, 18 Jul 2018 19:12:14 +0000 (19:12 +0000)]
filepath: updates doc to give case where WalkFunc info arg may be nil

If a filepath.WalkFunc is called with an non-nil err argument, it's possible
that the info argument will be nil. The comment above filepath.WalkFunc now
reflects this.

Fixes #26425

Change-Id: Ib9963b3344587d2993f1698c5a801f2d1286856b
GitHub-Last-Rev: 553fc266b570d0c47efe12b3b670f88112e3b334
GitHub-Pull-Request: golang/go#26435
Reviewed-on: https://go-review.googlesource.com/124635
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc/go1.11: mention major performance optimizations
Austin Clements [Wed, 18 Jul 2018 19:45:56 +0000 (15:45 -0400)]
doc/go1.11: mention major performance optimizations

Change-Id: I25b93a84996ab1c17d64089b4c2ffabdff3365ec
Reviewed-on: https://go-review.googlesource.com/124710
Reviewed-by: Austin Clements <austin@google.com>
6 years agodoc: update go1.11.html removing TODO about TLS offsets
Andrew Bonventre [Wed, 18 Jul 2018 19:35:12 +0000 (15:35 -0400)]
doc: update go1.11.html removing TODO about TLS offsets

Change-Id: Id06e5139f16cd7a85c59a3dcf2020cf647fcdea0
Reviewed-on: https://go-review.googlesource.com/124709
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agodoc: update go1.11.html with user annotation API additions
Andrew Bonventre [Wed, 18 Jul 2018 19:16:26 +0000 (15:16 -0400)]
doc: update go1.11.html with user annotation API additions

Change-Id: I357eea0efb04392e1a4671d20190a2052bf548de
Reviewed-on: https://go-review.googlesource.com/124706
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agodoc: update go1.11 release notes
Andrew Bonventre [Wed, 18 Jul 2018 19:04:02 +0000 (15:04 -0400)]
doc: update go1.11 release notes

Update text/scanner and text/template sections.

Change-Id: I1a273e99ff400870053cca63cea68fb7a9b56764
Reviewed-on: https://go-review.googlesource.com/124705
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agodoc/go1.11: remove unnecessary absolute link
Brad Fitzpatrick [Wed, 18 Jul 2018 18:27:20 +0000 (18:27 +0000)]
doc/go1.11: remove unnecessary absolute link

This doesn't auto-deploy to golang.org, only tip.golang.org.

Change-Id: I112743ada2c1393e21edcc9075127f40da9e6270
Reviewed-on: https://go-review.googlesource.com/124755
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/go1.11: link to module overview
Russ Cox [Wed, 18 Jul 2018 17:30:41 +0000 (13:30 -0400)]
doc/go1.11: link to module overview

Change-Id: Id381ee73e678ff4b025c1c35512a755ba49d6f81
Reviewed-on: https://go-review.googlesource.com/124702
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agodoc: fix a link in go1.11.html and flesh out a few sections
Brad Fitzpatrick [Wed, 18 Jul 2018 16:20:49 +0000 (16:20 +0000)]
doc: fix a link in go1.11.html and flesh out a few sections

Change-Id: Ic5b9ccb2772534cee77ffcaeee617c7d5edfb6fd
Reviewed-on: https://go-review.googlesource.com/124715
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc/go1.11: update runtime/pprof change note
Hana (Hyang-Ah) Kim [Wed, 18 Jul 2018 07:06:21 +0000 (03:06 -0400)]
doc/go1.11: update runtime/pprof change note

Mention the change in the behavior of go test -memprofile.

Change-Id: I0384f058298bd8fcfd2d97996464d46b4e419938
Reviewed-on: https://go-review.googlesource.com/124656
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc/go1.11: add space in Go version name
Alberto Donizetti [Wed, 18 Jul 2018 08:53:44 +0000 (10:53 +0200)]
doc/go1.11: add space in Go version name

Missed in CL 124516.

Change-Id: I6488196c8392987d69eca832ab4969aaafe1a26c
Reviewed-on: https://go-review.googlesource.com/124658
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc/go1.11: mention the libSystem.so change for iOS
Elias Naur [Wed, 18 Jul 2018 07:17:19 +0000 (09:17 +0200)]
doc/go1.11: mention the libSystem.so change for iOS

The change to make the runtime use libSystem.so macOS instead of
direct kernel calls applies to iOS as well.

Change-Id: I97ea86452ac5f7433aea58bbd3ff53a2eb2835e0
Reviewed-on: https://go-review.googlesource.com/124657
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: fix an arm64's comparison bug
Ben Shi [Wed, 18 Jul 2018 11:16:47 +0000 (11:16 +0000)]
cmd/compile: fix an arm64's comparison bug

The arm64 backend generates "TST" for "if uint32(a)&uint32(b) == 0",
which should be "TSTW".

fixes #26438

Change-Id: I7d64c30e3a840b43486bcd10eea2e3e75aaa4857
Reviewed-on: https://go-review.googlesource.com/124637
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agodoc/go1.11: add time package changes to release notes
Alberto Donizetti [Wed, 18 Jul 2018 10:00:16 +0000 (12:00 +0200)]
doc/go1.11: add time package changes to release notes

Change-Id: I6f8d9cc8997128d0076a3a3e82fe5155d53db40d
Reviewed-on: https://go-review.googlesource.com/124659
Reviewed-by: Rob Pike <r@golang.org>
6 years agocmd/cgo: don't report inconsistency error for incomplete typedef
Ian Lance Taylor [Wed, 18 Jul 2018 00:36:15 +0000 (17:36 -0700)]
cmd/cgo: don't report inconsistency error for incomplete typedef

In CLs 122575 and 123177 the cgo tool started explicitly looking up
typedefs. When there are two Go files using import "C", and the first
one has an incomplete typedef and the second one has a complete
version of the same typedef, then we will now record a version of the
first typedef which will not match the recorded version of the second
typedef, producing an "inconsistent definitions" error. Fix this by
silently merging incomplete typedefs with complete ones.

Fixes #26430

Change-Id: I9e629228783b866dd29b5c3a31acd48f6e410a2d
Reviewed-on: https://go-review.googlesource.com/124575
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agodoc/gopher: add model sheet
Rob Pike [Wed, 18 Jul 2018 01:32:40 +0000 (11:32 +1000)]
doc/gopher: add model sheet

This should have been added to the repo after Renee's Gophercon
keynote. I will link to it from the FAQ.

Change-Id: I0e5b88690e288827591d27b99420d3a449f7f662
Reviewed-on: https://go-review.googlesource.com/124615
Reviewed-by: Andrew Gerrand <adg@golang.org>
6 years agocmd/go/internal/module: allow v0.0.0 pseudoversion for gopkg.in/check.v1
Russ Cox [Tue, 17 Jul 2018 02:40:05 +0000 (22:40 -0400)]
cmd/go/internal/module: allow v0.0.0 pseudoversion for gopkg.in/check.v1

It worked once. It needs to keep working.

Change-Id: Iaa43726e1c78f0c4a20b5805c7c2bfa76fab2489
Reviewed-on: https://go-review.googlesource.com/124383
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: add clean -modcache
Russ Cox [Tue, 17 Jul 2018 01:37:44 +0000 (21:37 -0400)]
cmd/go: add clean -modcache

We need an easy way to remove $GOPATH/src/mod,
especially since all the directories are marked read-only.

Change-Id: Ib9e8e47e50048f55ecc4de0229b06c4a416ac114
Reviewed-on: https://go-review.googlesource.com/124382
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go/internal/modfetch: make subdirectories unwritable too
Russ Cox [Tue, 17 Jul 2018 01:29:39 +0000 (21:29 -0400)]
cmd/go/internal/modfetch: make subdirectories unwritable too

The top-level directory in a module was marked unwritable
but not the subdirectories. Fix that.

Change-Id: Ia57e5343624753851d9fe1ddfe496b870b67f924
Reviewed-on: https://go-review.googlesource.com/124381
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go/internal/modfetch: restrict file names in zip files, avoid case-insensitive...
Russ Cox [Mon, 16 Jul 2018 04:47:24 +0000 (00:47 -0400)]
cmd/go/internal/modfetch: restrict file names in zip files, avoid case-insensitive collisions

Within the zip file for a given module, disallow names that are invalid
on various operating systems (mostly Windows), and disallow
having two different paths that are case-fold-equivalent.
Disallowing different case-fold-equivalent paths means the
zip file content is safe for case-insensitive file systems.

There is more we could do to relax the rules later, but I think
this should be enough to avoid digging a hole in the early days
of modules that's hard to climb out of later.

In tests on my repo test corpus, the repos now rejected are:

github.com/vjeantet/goldap v0.0.0-20160521203625-ea702ca12a40
"doc/RFC 4511 - LDAP: The Protocol.txt": invalid char ':'

github.com/ChimeraCoder/anaconda v0.0.0-20160509014622-91bfbf5de08d
"json/statuses/show.json?id=404409873170841600": invalid char '?'

github.com/bmatcuk/doublestar
"test/a☺b": invalid char '☺'

github.com/kubernetes-incubator/service-catalog v0.1.10
"cmd/svcat/testdata/responses/clusterserviceclasses?fieldSelector=spec.externalName=user-provided-service.json": invalid char '?'

The : and ? are reserved on Windows,
and the : is half-reserved (and quite confusing) on macOS.
The ☺ is perhaps an overreach, but I am not convinced
that allowing all of category So is safe; certainly Sk is not.

Change-Id: I83b6ac47ce6c442f726f1036bccccdb15553c0af
Reviewed-on: https://go-review.googlesource.com/124380
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go/internal/modfetch: do not rely on file system for case sensitivity
Russ Cox [Mon, 16 Jul 2018 03:42:16 +0000 (23:42 -0400)]
cmd/go/internal/modfetch: do not rely on file system for case sensitivity

Over time there may exist two modules with names that differ only in case.
On systems with case-insensitive file systems, we need to make sure those
modules do not collide in the download cache.

Do this by using the new "safe encoding" for file system paths as well as
proxy paths.

Fixes #25992.

Change-Id: I717a9987a87ad5c6927d063bf30d10d9229498c9
Reviewed-on: https://go-review.googlesource.com/124379
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go/internal/module: define fs-safe module path encoding
Russ Cox [Mon, 16 Jul 2018 02:56:37 +0000 (22:56 -0400)]
cmd/go/internal/module: define fs-safe module path encoding

Module paths, like import paths, are case-sensitive, for better or worse.
But not all file systems distinguish file paths with different cases.
If we are going to use module paths to construct file system paths,
we must apply an encoding that distinguishes case without relying
upon the file system to do it.

This CL defines that encoding, the "safe module path encoding".
Module paths today are ASCII-only with limited punctuation,
so the safe module path encoding is to convert the whole path
to lower case and insert an ! before every formerly upper-case letter:
github.com/Sirupsen/logrus is stored as github.com/!sirupsen/logrus.

Although this CL defines the encoding, it does not change the rest
of the go command to use the encoding. That will be done in
follow-up CLs.

Change-Id: I06e6188dcfcbbc1d88674f7c95e1cb45cb476238
Reviewed-on: https://go-review.googlesource.com/124378
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agosyscall: update check for UserNS support for CentOS 7.5+
EduRam [Tue, 17 Jul 2018 22:59:35 +0000 (22:59 +0000)]
syscall: update check for UserNS support for CentOS 7.5+

Fixes #26385

Change-Id: I5594564f42898a71d30531e5132bddb3a6915247
GitHub-Last-Rev: fbd7b38b0419e21ecd22fe802ede5c0ee3f14a9a
GitHub-Pull-Request: golang/go#26427
Reviewed-on: https://go-review.googlesource.com/124555
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: search test imports when matching -coverpkg
Ian Lance Taylor [Fri, 6 Jul 2018 22:22:56 +0000 (15:22 -0700)]
cmd/go: search test imports when matching -coverpkg

Fixes #25093

Change-Id: If283275e2b73621ade56d014e60c2d18199b366c
Reviewed-on: https://go-review.googlesource.com/122555
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agodoc: improve the garbage collection discussion
Rob Pike [Tue, 17 Jul 2018 09:57:24 +0000 (19:57 +1000)]
doc: improve the garbage collection discussion

Bring it up to date with recent terminology, mention new approaches
such as in Rust, and link to the new blog post.

Change-Id: I1d0b121e6f8347c3cf2c8ca0d8adc8285ce59ef1
Reviewed-on: https://go-review.googlesource.com/124475
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc/go1.11: compiler and runtime release notes
Austin Clements [Tue, 17 Jul 2018 21:49:37 +0000 (17:49 -0400)]
doc/go1.11: compiler and runtime release notes

Change-Id: I487bdf0c828d28b2122bd93934dc5a9a5dbc6a00
Reviewed-on: https://go-review.googlesource.com/124517
Reviewed-by: Austin Clements <austin@google.com>
6 years agodoc/go1.11: fix some typos
Austin Clements [Tue, 17 Jul 2018 21:27:26 +0000 (17:27 -0400)]
doc/go1.11: fix some typos

Change-Id: I3c0cb9b56776d8cc78a96ef012385c31f9f0e146
Reviewed-on: https://go-review.googlesource.com/124516
Reviewed-by: Austin Clements <austin@google.com>
6 years agopath/filepath: make Walk example runnable in the playground
Mostyn Bramley-Moore [Wed, 4 Jul 2018 21:32:59 +0000 (23:32 +0200)]
path/filepath: make Walk example runnable in the playground

Relates to #9679

Change-Id: I68951f664d2a03812dae309c580c181869d8af21
Reviewed-on: https://go-review.googlesource.com/122237
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: minor go1.11 changes
Filippo Valsorda [Mon, 16 Jul 2018 22:14:58 +0000 (18:14 -0400)]
doc: minor go1.11 changes

CL 124135 follow-ups.

Change-Id: Ib7e2066bd2d18851561e03386709a1b42b50fcef
Reviewed-on: https://go-review.googlesource.com/124136
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agocmd/go: run git log with --no-show-signature
Frank Schroeder [Sat, 14 Jul 2018 21:58:07 +0000 (21:58 +0000)]
cmd/go: run git log with --no-show-signature

Git timestamp parsing is broken when fetching modules if the
local git configuration has 'log.showsignature=true'.

Fixes #26388

Change-Id: I47f92381784072335a2a465de56092106c616108
GitHub-Last-Rev: 96f988c0a2dd39a5747ec4a7bad05e7e8ee0d384
GitHub-Pull-Request: golang/go#26389
Reviewed-on: https://go-review.googlesource.com/123958
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/cgo: update JNI's jobject to uintptr check for newer Android NDKs
Steeve Morin [Tue, 17 Jul 2018 15:55:01 +0000 (15:55 +0000)]
cmd/cgo: update JNI's jobject to uintptr check for newer Android NDKs

In Android's NDK16, jobject is now declared as:
    #ifdef __cplusplus
    class _jobject {};
    typedef _jobject*       jobject;
    #else /* not __cplusplus */
    typedef void*           jobject;
    #endif

This makes the jobject to uintptr check fail because it expects the
following definition:
    struct _jobject;
    typedef struct _jobject *jobject;

Update the type check to handle that new type definition in both C and
C++ modes.

Fixes #26213

Change-Id: Ic36d4a5176526998d2d5e4e404f8943961141f7a
GitHub-Last-Rev: 42037c3c584579c2b3281c25372b830e864e7aec
GitHub-Pull-Request: golang/go#26221
Reviewed-on: https://go-review.googlesource.com/122217
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agodoc/go1.11: explain new vet typechecking behaviour in release notes
Alberto Donizetti [Thu, 28 Jun 2018 18:22:13 +0000 (20:22 +0200)]
doc/go1.11: explain new vet typechecking behaviour in release notes

Since Go1.10, go test runs vet on the tests before executing them.

Moreover, the vet tool typechecks the package under analysis with
go/types before running. In Go1.10, a typechecking failure just caused
a warning to be printed. In Go1.11, a typechecking failure will cause
vet to exit with a fatal error (see Issue #21287).

This means that starting with Go1.11, tests that don't typecheck will
fail immediately. This would not normally be an issue, since a test
that doesn't typecheck shouldn't even compile, and it should already
be broken.

Unfortunately, there's a bug in gc that makes it accept programs with
unused variables inside a closure (Issue #3059). This means that a
test with an unused variable inside a closure, that compiled and
passed in Go1.10, will fail in the typechecking step of vet starting
with Go1.11.

Explain this in the 1.11 release notes.

Fixes #26109

Change-Id: I970c1033ab6bc985d8c64bd24f56e854af155f96
Reviewed-on: https://go-review.googlesource.com/121455
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoRevert "runtime: fix lldb test after DWARF compression"
Austin Clements [Tue, 17 Jul 2018 15:38:35 +0000 (11:38 -0400)]
Revert "runtime: fix lldb test after DWARF compression"

This reverts commit c99300229de4e69220790c71da14785dc52c3d68.

The original CL skipped the lldb test if it couldn't read compressed
DWARF, but lldb can never read compressed DWARF, so this effectively
disabled this test unconditionally.

The previous commit disabled DWARF compression for this test, so the
test now works on its own merits again. This CL reverts the change to
skip the test so we don't simply mask lldb failures.

Updates #25925.

Change-Id: I3e1c787b658257b542c3c70807065dde9cfe05ee
Reviewed-on: https://go-review.googlesource.com/124386
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoruntime: disable compressed DWARF for lldb test
Austin Clements [Tue, 17 Jul 2018 15:36:29 +0000 (11:36 -0400)]
runtime: disable compressed DWARF for lldb test

lldb doesn't support compressed DWARF, so right now we're just always
skipping the lldb test. This CL makes the test run again by disabling
compressed DWARF just for this test.

Updates #25925.

Change-Id: Ib9ddc442305fe6d37060d48f36bc4458b6fd8c86
Reviewed-on: https://go-review.googlesource.com/124385
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: keep autos if their address reaches a control value
Michael Munday [Tue, 17 Jul 2018 07:39:30 +0000 (08:39 +0100)]
cmd/compile: keep autos if their address reaches a control value

Autos must be kept if their address reaches the control value of a
block. We didn't see this before because it is rare for an auto's
address to reach a control value without also reaching a phi or
being written to memory. We can probably optimize away the
comparisons that lead to this scenario since autos cannot alias
with pointers from elsewhere, however for now we take the
conservative approach and just ensure the auto is properly
initialised if its address reaches a control value.

Fixes #26407.

Change-Id: I02265793f010a9e001c3e1a5397c290c6769d4de
Reviewed-on: https://go-review.googlesource.com/124335
Reviewed-by: David Chase <drchase@google.com>
6 years agocmd/go: add new test script facility
Russ Cox [Thu, 12 Jul 2018 16:36:34 +0000 (12:36 -0400)]
cmd/go: add new test script facility

The original cmd/go tests were tiny shell scripts
written against a library of shell functions.
They were okay to write but difficult to run:
you couldn't select individual tests (with -run)
they didn't run on Windows, they were slow, and so on.

CL 10464 introduced go_test.go's testgo framework
and later CLs translated the test shell script over to
individual go tests. This let us run tests selectively,
run tests on Windows, run tests in parallel, isolate
different tests, and so on. It was a big advance.

The tests had always been awkward to write.
Here was the first test in test.bash:

TEST 'file:line in error messages'
# Test that error messages have file:line information at beginning of
# the line. Also test issue 4917: that the error is on stderr.
d=$(TMPDIR=/var/tmp mktemp -d -t testgoXXX)
fn=$d/err.go
echo "package main" > $fn
echo 'import "bar"' >> $fn
./testgo run $fn 2>$d/err.out || true
if ! grep -q "^$fn:" $d/err.out; then
echo "missing file:line in error message"
cat $d/err.out
ok=false
fi
rm -r $d

The final Go version of this test was:

func TestFileLineInErrorMessages(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
tg.tempFile("err.go", `package main; import "bar"`)
path := tg.path("err.go")
tg.runFail("run", path)
shortPath := path
if rel, err := filepath.Rel(tg.pwd(), path); err == nil && len(rel) < len(path) {
shortPath = rel
}
tg.grepStderr("^"+regexp.QuoteMeta(shortPath)+":", "missing file:line in error message")
}

It's better but still quite difficult to skim.

This CL introduces a new facility meant as a successor to the testgo
approach that brings back the style of writing tests as little scripts,
but they are now scripts in a built-for-purpose shell-like language,
not bash itself. In this new form, the test above is a single file,
testdata/script/fileline.txt:

# look for short, relative file:line in error message
! go run ../../gopath/x/y/z/err.go
stderr ^..[\\/]x[\\/]y[\\/]z[\\/]err.go:

-- ../x/y/z/err.go --
package main; import "bar"

The file is a txtar text archive (see CL 123359) in which the leading comment
is the test script and the files are the initial state of the temporary file
system where the script runs.

Each script runs as a subtest, so that they can still be selected individually.

The scripts are kept isolated from each other by default,
so all script subtests are treated as parallel tests, for the
testing package to run in parallel. Even for the 15 tests in
this CL, that cuts the time for TestScript from 5.5s to 2.5s.

The scripts do not have access to the cmd/go source directory,
nor to cmd/go/testdata, so they are prevented from creating temporary
files in those places or modifying existing ones. (Many existing tests
scribble in testdata, unfortunately, especially testdata/pkg when
they run builds with GOPATH=testdata.)

This CL introduces the script facility and converts 15 tests.
The txtar archive form will allow us to delete the large trees of trivial
files in testdata; a few are deleted in this CL.

See testdata/script/README for details and a larger conversion example.

As part of converting testdata/script/test_badtest.txt,
I discovered that 'go test' was incorrectly printing a FAIL line
to stderr (not stdout) in one corner case. This CL fixes that
to keep the test passing.

Future CLs will convert more tests.

Change-Id: I11aa9e18dd2d4c7dcd8e310dbdc6a1ea5f7e54c1
Reviewed-on: https://go-review.googlesource.com/123577
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: update Usage section of the FAQ
Rob Pike [Mon, 16 Jul 2018 10:32:05 +0000 (20:32 +1000)]
doc: update Usage section of the FAQ

This is close to a complete rewrite, as the content was pretty old.

The CL includes links to the Wiki for information about companies
using Go, a new section about IDEs and editors¹, and a restatement
of the foreign function interface story. It also modernizes and
expands a little on the use of Go inside Google.

¹ Ed is the standard editor.

Change-Id: I5e54aafa53d00d86297b2691960a376b40f6225b
Reviewed-on: https://go-review.googlesource.com/123922
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: rewrite run-on sentence in garbage collection discussion
Rob Pike [Mon, 16 Jul 2018 21:22:41 +0000 (07:22 +1000)]
doc: rewrite run-on sentence in garbage collection discussion

Change-Id: I60cb7010448757ca4c7a2973bee2277b3d5fc439
Reviewed-on: https://go-review.googlesource.com/124175
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: fix handling of vet.cfg with buggyInstall
Ian Lance Taylor [Tue, 17 Jul 2018 02:09:24 +0000 (19:09 -0700)]
cmd/go: fix handling of vet.cfg with buggyInstall

The vet action assumes that a.Deps[0] is the compilation action for
which vet information should be generated. However, when using
-linkshared, the action graph is built with a ModeBuggyInstall action
to install the shared library built from the compilation action.
Adjust the set up of the vet action accordingly. Also don't clean up
the working directory after completing the buggy install.

Updates #26400

Change-Id: Ia51f9f6b8cde5614a6f2e41b6207478951547770
Reviewed-on: https://go-review.googlesource.com/124275
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go/internal/cache: squelch cache init warnings when $HOME is /
Zev Goldstein [Mon, 9 Jul 2018 02:31:28 +0000 (22:31 -0400)]
cmd/go/internal/cache: squelch cache init warnings when $HOME is /

Docker sets $HOME to / when running with a UID that doesn't exist within
the container.  This not  uncommon on CI servers.

Fixes #26280

Change-Id: Ic7ff62b41403fe6e7c0cef12814667ef73f6c954
Reviewed-on: https://go-review.googlesource.com/122487
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agohttp/internal: document final CRLF behavior on chunkedWriter
Eric Daniels [Tue, 17 Jul 2018 00:49:55 +0000 (00:49 +0000)]
http/internal: document final CRLF behavior on chunkedWriter

Change-Id: I0f76b40dbfda2d382c88aec377db1851c4ac7441

Change-Id: I0f76b40dbfda2d382c88aec377db1851c4ac7441
GitHub-Last-Rev: ab42559278d8cba9e025b431a459d117500a73da
GitHub-Pull-Request: golang/go#26410
Reviewed-on: https://go-review.googlesource.com/124255
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go: handle relative temp dir
Russ Cox [Fri, 13 Jul 2018 19:55:50 +0000 (15:55 -0400)]
cmd/go: handle relative temp dir

Most programs seem to accept a relative temp dir, as weird as that might be.

Also, the meaning of relative is a little more fluid on Windows:
TMP=\temp is relative (to the current drive) but will work well enough.

Also, Windows GetTempPath automatically converts a relative
%TMP% into an absolute path, so we'd be imposing different
behavior for GOTMPDIR vs TMP.

It seems easier and more consistent to just impose the obvious
meaning than to add an error we can only implement some of
the time.

Originally got here because "cmd/go:" should be"go:" in error message,
but the error message is gone now.

Fixes #23264.

Change-Id: I3c3fb801cbd5e652364f1f62bb3881e9317e3581
Reviewed-on: https://go-review.googlesource.com/123876
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/internal/buildid: close ELF file after reading note
Ian Lance Taylor [Mon, 16 Jul 2018 23:17:27 +0000 (16:17 -0700)]
cmd/internal/buildid: close ELF file after reading note

Updates #26400

Change-Id: I1747d1f1018521cdfa4b3ed13412a944829967cf
Reviewed-on: https://go-review.googlesource.com/124235
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoarchive/zip: fix regression when writing directories
Joe Tsai [Mon, 16 Jul 2018 20:05:25 +0000 (13:05 -0700)]
archive/zip: fix regression when writing directories

Several adjustments:

1) When encoding the FileHeader for a directory, explicitly set all of the sizes
to zero regardless of their prior values. These values are currently populated
by FileInfoHeader as it calls os.FileInfo.Size regardless of whether the file is
a directory or not. We avoid fixing FileInfoHeader now as it is too late in the
release cycle (see #24082).

We silently adjust slightly wrong FileHeader fields as opposed to returning
an error because the CreateHeader method already does such mutations
(e.g., for UTF-8 detection, data descriptor, etc).

2) Have dirWriter.Write only return an error if some number of bytes are written.
Some code still call Write for both normal files and directories, but just pass
an empty []byte to Write for directories.

Change-Id: I85492a31356107fcf76dc89ceb00a28853754289
Reviewed-on: https://go-review.googlesource.com/124155
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: populate and add go1.11 notes related to crypto
Filippo Valsorda [Mon, 16 Jul 2018 20:25:06 +0000 (16:25 -0400)]
doc: populate and add go1.11 notes related to crypto

Change-Id: I8163d06e5099d7ac39b04ccadf7f6533967db2f5
Reviewed-on: https://go-review.googlesource.com/124135
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agocrypto/x509: add GODEBUG option x509ignoreCN=1
Filippo Valsorda [Thu, 12 Jul 2018 23:19:45 +0000 (19:19 -0400)]
crypto/x509: add GODEBUG option x509ignoreCN=1

When x509ignoreCN=1 is present in GODEBUG, ignore the deprecated Common
Name field. This will let people test a behavior we might make the
default in the future, and lets a final class of certificates avoid the
NameConstraintsWithoutSANs error.

Updates #24151

Change-Id: I1c397aa1fa23777b9251c311d02558f9a5bdefc0
Reviewed-on: https://go-review.googlesource.com/123695
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
6 years agocrypto/x509: ignore Common Name when it does not parse as a hostname
Filippo Valsorda [Wed, 11 Jul 2018 19:59:56 +0000 (15:59 -0400)]
crypto/x509: ignore Common Name when it does not parse as a hostname

The Common Name is used as a hostname when there are no Subject
Alternative Names, but it is not restricted by name constraints. To
protect against a name constraints bypass, we used to require SANs for
constrained chains. See the NameConstraintsWithoutSANs error.

This change ignores the CN when it does not look like a hostname, so we
can avoid returning NameConstraintsWithoutSANs.

This makes it possible to validate certificates with non-hostname CN
against chains that use name constraints to disallow all names, like the
Estonian IDs.

Updates #24151

Change-Id: I798d797990720a01ad9b5a13336756cc472ebf44
Reviewed-on: https://go-review.googlesource.com/123355
Reviewed-by: Adam Langley <agl@golang.org>
6 years agomisc/cgo: fix darwin test, again
Keith Randall [Mon, 16 Jul 2018 17:45:25 +0000 (10:45 -0700)]
misc/cgo: fix darwin test, again

TARGET_OS_OSX is the right macro, but it also was only introduced
in 1.12.  For 1.11 and earlier a reasonable substitution is
TARGET_OS_IPHONE == 0.

Update #24161
Update #26355

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

6 years agodoc: move the go1.11 "all" section elsewhere, add os/signal.Ignored, GOMIPS64
Brad Fitzpatrick [Mon, 16 Jul 2018 18:37:13 +0000 (18:37 +0000)]
doc: move the go1.11 "all" section elsewhere, add os/signal.Ignored, GOMIPS64

Change-Id: Ice8f82a6288eeadfb8efd7628444166a447831da
Reviewed-on: https://go-review.googlesource.com/124096
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: add more to go1.11, sort, remove dups
Brad Fitzpatrick [Mon, 16 Jul 2018 18:22:26 +0000 (18:22 +0000)]
doc: add more to go1.11, sort, remove dups

Change-Id: I20a82f6b47cd3ab4ca22d222e6d8a2c59d57e2a4
Reviewed-on: https://go-review.googlesource.com/124095
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: flesh out go1.11 notes
Brad Fitzpatrick [Mon, 16 Jul 2018 17:05:59 +0000 (17:05 +0000)]
doc: flesh out go1.11 notes

Change-Id: I0152d3c1d980e271fbcdb9d5def094d3c837a4f4
Reviewed-on: https://go-review.googlesource.com/124055
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: add net/http additions to go1.11 notes
Brad Fitzpatrick [Mon, 16 Jul 2018 16:35:04 +0000 (16:35 +0000)]
doc: add net/http additions to go1.11 notes

Change-Id: Ib2da2b0ceb33867a41b0b9b7e4dcecb11f964b73
Reviewed-on: https://go-review.googlesource.com/124035
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/cgo: add note about bug writing C pointers to uninitialized C memory
Ian Lance Taylor [Thu, 12 Jul 2018 18:57:05 +0000 (11:57 -0700)]
cmd/cgo: add note about bug writing C pointers to uninitialized C memory

Describe the problem as a bug, since it is not implied by the rest of
the pointer passing rules, and it may be possible to fix it.

Updates #19928

Change-Id: I2d336e7336b2a215c0b8cf909a203201ef1b054e
Reviewed-on: https://go-review.googlesource.com/123658
Reviewed-by: Austin Clements <austin@google.com>
6 years agocmd/go: make TestNewReleaseRebuildsStalePackagesInGOPATH pass again
Ian Lance Taylor [Fri, 13 Jul 2018 16:57:17 +0000 (09:57 -0700)]
cmd/go: make TestNewReleaseRebuildsStalePackagesInGOPATH pass again

The test TestNewReleaseRebuildsStalePackagesInGOPATH is not run in
short mode, so people tend to not notice when it fails. It was failing
due to the build cache. Make it pass again by 1) changing it to modify
the package in a way visible to the compiler, so that the change is
not hidden by caching; 2) accepting "not installed but available in
build cache" as always being a valid reason for a stale package, as go
list does not try to figure out an underlying reason for why a package
is stale when it finds it in the build cache but not installed.

Updates #24436

Change-Id: Iaeaa298f153451ec913a653dd4e6da79a33055bb
Reviewed-on: https://go-review.googlesource.com/123815
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agodoc/go1.11: update with latest output from x/build/cmd/relnote
Andrew Bonventre [Mon, 16 Jul 2018 14:22:18 +0000 (10:22 -0400)]
doc/go1.11: update with latest output from x/build/cmd/relnote

Change-Id: I4055ecc39b1b250cce7b32241f13dbc05567361f
Reviewed-on: https://go-review.googlesource.com/124015
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agoruntime/pprof: add a fake mapping when /proc/self/maps is unavailable
Hana (Hyang-Ah) Kim [Fri, 13 Jul 2018 20:11:24 +0000 (16:11 -0400)]
runtime/pprof: add a fake mapping when /proc/self/maps is unavailable

Profile's Mapping field is currently populated by reading /proc/self/maps.
On systems where /proc/self/maps is not available, the profile generated
by Go's runtime will not have any Mapping entry. Pprof command then adds
a fake entry and links all Location entries in the profile with the fake
entry to be used during symbolization.
https://github.com/google/pprof/blob/a8644067d5a3c9a6386e7c88fa4a3d9d37877ca3/internal/driver/fetch.go#L437

The fake entry is not enough to suppress the error or warning messages
pprof command produces. We need to tell pprof that Location entries are
symbolized already by Go runtime and pprof does not have to attempt to
perform further symbolization.

In #25743, we made Go runtime mark Mapping entries with HasFunctions=true
when all Location entries from the Mapping entries are successfully
symbolized. This change makes the Go runtime add a fake mapping entry,
otherwise the pprof command tool would add, and set the HasFunctions=true
following the same logic taken when the real mapping information is
available.

Updates #19790.
Fixes #26255. Tested pprof doesn't report the error message any more
for pure Go program.

Change-Id: Ib12b62e15073f5d6c80967e44b3e8709277c11bd
Reviewed-on: https://go-review.googlesource.com/123779
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc: update Design and Types sections of the FAQ
Rob Pike [Sat, 14 Jul 2018 06:46:57 +0000 (16:46 +1000)]
doc: update Design and Types sections of the FAQ

Update #26107.

Change-Id: I8bfa5b01ce953c53f7fd7a866d0ece61ba04c618
Reviewed-on: https://go-review.googlesource.com/123919
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: update Values, Writing Code, and Pointers and Allocation sections of the FAQ
Rob Pike [Sat, 14 Jul 2018 04:52:31 +0000 (14:52 +1000)]
doc: update Values, Writing Code, and Pointers and Allocation sections of the FAQ

Significant surgery done to the Versioning section, bringing it closer to
modern thinking.

Also add a question about constants.

Update #26107.

Change-Id: Icf70b7228503c6baaeab0b95ee3e6bee921575aa
Reviewed-on: https://go-review.googlesource.com/123918
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: update Implementation and Performance sections of the FAQ
Rob Pike [Sat, 14 Jul 2018 04:06:28 +0000 (14:06 +1000)]
doc: update Implementation and Performance sections of the FAQ

Changes are mostly about making more about now than about the past,
changing some verb tenses, and mentioning gollvm (which should
be pronounced "gollum" if you ask me).

Update #26107

Change-Id: I6c14f42b9fc2684259d4ba8bc149d7ec9bb83d15
Reviewed-on: https://go-review.googlesource.com/123917
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: rearrange the description of GOMAXPROCS
Rob Pike [Thu, 12 Jul 2018 23:08:13 +0000 (09:08 +1000)]
doc: rearrange the description of GOMAXPROCS

The old text was written when it was only 1 by default, which
changed a long time ago.

Also add a note that GOMAXPROCS does not limit the total
number of threads.

Change-Id: I104ccd7266d11335320a4d7f5671fb09ed641f88
Reviewed-on: https://go-review.googlesource.com/123916
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agomisc/cgo: fix test on iOS
Keith Randall [Sun, 15 Jul 2018 00:18:45 +0000 (17:18 -0700)]
misc/cgo: fix test on iOS

The test in CL 123715 doesn't work on iOS, it needs to use a different
version scheme to determine whether SecKeyAlgorithm and friends exist.
Restrict the old version test to OSX only.

The same problem occurs on iOS: the functions tested don't exist before
iOS 10.  But we don't have builders below iOS 10, so it isn't a big issue.
If we ever get older builders, or someone wants to run all.bash on an
old iOS, they'll need to figure out the right incantation.

Update #24161
Update #26355

Change-Id: Ia3ace86b00486dc172ed00c0c6d668a95565bff7
Reviewed-on: https://go-review.googlesource.com/123959
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/vet,sync: check lock values more precisely
Dan Kortschak [Sun, 1 Jul 2018 00:03:55 +0000 (09:33 +0930)]
cmd/vet,sync: check lock values more precisely

Fixes #26165

Change-Id: I1f3bd193af9b6f8461c736330952b6e50d3e00d9
Reviewed-on: https://go-review.googlesource.com/121876
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agonet/http: don't cancel Request.Context on pipelined Server requests
Brad Fitzpatrick [Fri, 13 Jul 2018 19:31:35 +0000 (19:31 +0000)]
net/http: don't cancel Request.Context on pipelined Server requests

See big comment in code.

Fixes #23921

Change-Id: I2dbd1acc2e9da07a71f9e0640aafe0c59a335627
Reviewed-on: https://go-review.googlesource.com/123875
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoos/exec: document ExtraFiles is not supported on windows
Adam Shannon [Fri, 13 Jul 2018 18:44:51 +0000 (13:44 -0500)]
os/exec: document ExtraFiles is not supported on windows

Fixes #26182

Change-Id: I1181e191f4742f166c9b67a6f41332a237cf0ede
Reviewed-on: https://go-review.googlesource.com/123855
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: fix module replace flag parsed bug
Baokun Lee [Fri, 13 Jul 2018 20:17:19 +0000 (04:17 +0800)]
cmd/go: fix module replace flag parsed bug

In CL 122404, we change -replace syntax from => to =.
And we also need to change this and the tests.

Fixes golang/go#26373.

Change-Id: I2d4e85e10c1578540cc7673b93d849270940d776
Reviewed-on: https://go-review.googlesource.com/123778
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>

6 years agocmd/go: remove windows Skip in test that wasn't removed
Brad Fitzpatrick [Fri, 13 Jul 2018 20:56:46 +0000 (20:56 +0000)]
cmd/go: remove windows Skip in test that wasn't removed

Was supposed to be removed from CL 123757

Change-Id: I74405adab58be103f8e4a0c2405567f480a0e622
Reviewed-on: https://go-review.googlesource.com/123895
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: fix TestModFindModulePath on Windows
Russ Cox [Fri, 13 Jul 2018 20:38:24 +0000 (16:38 -0400)]
cmd/go: fix TestModFindModulePath on Windows

The os.RemoveAll(tg.tempdir) was not a good idea.

Change-Id: I6f78cff887044186649cbf3ee04a58abdbcb71e2
Reviewed-on: https://go-review.googlesource.com/123757
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agoregexp: reword Match documentation to be more like Find
Russ Cox [Fri, 13 Jul 2018 14:28:56 +0000 (10:28 -0400)]
regexp: reword Match documentation to be more like Find

Before:

  // Find returns a slice holding the text of the leftmost match in b of the regular expression.

  // Match checks whether a textual regular expression matches a byte slice.

After:

  // Match reports whether the byte slice b contains any match of the regular expression re.

The use of different wording for Find and Match always makes me think
that Match required the entire string to match while Find clearly allows
a substring to match.

This CL makes the Match wording correspond more closely to Find,
to try to avoid that confusion.

Change-Id: I97fb82d5080d3246ee5cf52abf28d2a2296a5039
Reviewed-on: https://go-review.googlesource.com/123736
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/link: eliminate a couple of unused DWARF attrs
Than McIntosh [Wed, 11 Jul 2018 16:30:05 +0000 (12:30 -0400)]
cmd/link: eliminate a couple of unused DWARF attrs

The linker's DWARF generation occasionally computes and attaches an
attribute X to a type even though the type's abbrev doesn't have the
specified attr. For example, the DW_TAG_subroutine_type abbrev entry
has no type attribute, but a type attr is given to it (wasting
memory). Similarly there are some places where a byte size attr is
added to a DIE whose abbrev lacks that attr. This patch trims away a
few of these not-needed attrs, saving some very tiny amount of memory.

Updates #26186

Change-Id: I69e853df468ac54b07772a614b4106d7c4dae01d
Reviewed-on: https://go-review.googlesource.com/123296
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoruntime: check tgkill error in Debug tests
Ian Lance Taylor [Wed, 11 Jul 2018 04:07:55 +0000 (21:07 -0700)]
runtime: check tgkill error in Debug tests

Updates #25519

Change-Id: Ibcdf948fd38d8d02d467b62213566ec0d7ce0d6a
Reviewed-on: https://go-review.googlesource.com/123180
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agohttp/http/httputil: add ReverseProxy.ErrorHandler
Julien Salleyron [Mon, 13 Nov 2017 22:32:07 +0000 (23:32 +0100)]
http/http/httputil: add ReverseProxy.ErrorHandler

This permits specifying an ErrorHandler to customize the RoundTrip
error handling if the backend fails to return a response.

Fixes #22700
Fixes #21255

Change-Id: I8879f0956e2472a07f584660afa10105ef23bf11
Reviewed-on: https://go-review.googlesource.com/77410
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go: call flag.Parse to properly initialize test environment variables
Jakub Čajka [Fri, 13 Jul 2018 13:23:12 +0000 (15:23 +0200)]
cmd/go: call flag.Parse to properly initialize test environment variables

Executing tests in src/cmd/go/internal/modfetch/codehost/git_test.go in enviroment
witout outside connectivity in to the internet results in tests failure:

2018/07/13 14:31:14 git clone --mirror https://vcs-test.golang.org/git/gitrepo1 /tmp/gitrepo-test-996701800/gitrepo2 in : exit status 128:
        Cloning into bare repository '/tmp/gitrepo-test-996701800/gitrepo2'...
        fatal: unable to access 'https://vcs-test.golang.org/git/gitrepo1/': Could not resolve host: vcs-test.golang.org
FAIL    cmd/go/internal/modfetch/codehost       0.307s

Fixes #26007

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