1
0
mirror of https://github.com/golang/go synced 2024-09-30 17:38:33 -06:00
Commit Graph

29982 Commits

Author SHA1 Message Date
David Crawshaw
13c6572341 plugin: mention OS X support and concurrency
Change-Id: I4270bf81511a5bf80ed146f5e66e4f8aeede2aa2
Reviewed-on: https://go-review.googlesource.com/31463
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-19 17:24:19 +00:00
Robert Griesemer
023bb034e9 spec: slightly more realistic example for type assertions
For #17428.

Change-Id: Ia902b50cf0c40e3c2167fb573a39d328331c38c7
Reviewed-on: https://go-review.googlesource.com/31449
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-19 17:16:55 +00:00
Brad Fitzpatrick
1e3dc3d5d4 syscall: make Utimes on Solaris match all the other geese
Updates #14892

Change-Id: I640c6e1635ccdf611f219521a7d297a9885c4cb3
Reviewed-on: https://go-review.googlesource.com/31446
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-19 13:55:50 +00:00
Brad Fitzpatrick
4859f6a416 net/http: make NewRequest set empty Body nil, don't peek Read Body in Transport
This CL makes NewRequest set Body nil for known-zero bodies, and makes
the http1 Transport not peek-Read a byte to determine whether there's
a body.

Background:

Many fields of the Request struct have different meanings for whether
they're outgoing (via the Transport) or incoming (via the Server).

For outgoing requests, ContentLength and Body are documented as:

	// Body is the request's body.
	//
	// For client requests a nil body means the request has no
	// body, such as a GET request. The HTTP Client's Transport
	// is responsible for calling the Close method.
	Body io.ReadCloser

	// ContentLength records the length of the associated content.
	// The value -1 indicates that the length is unknown.
	// Values >= 0 indicate that the given number of bytes may
	// be read from Body.
	// For client requests, a value of 0 with a non-nil Body is
	// also treated as unknown.
	ContentLength int64

Because of the ambiguity of what ContentLength==0 means, the http1 and
http2 Transports previously Read the first byte of a non-nil Body when
the ContentLength was 0 to determine whether there was an actual body
(with a non-zero length) and ContentLength just wasn't populated, or
it was actually empty.

That byte-sniff has been problematic and gross (see #17480, #17071)
and was removed for http2 in a previous commit.

That means, however, that users doing:

    req, _ := http.NewRequest("POST", url, strings.NewReader(""))

... would not send a Content-Length header in their http2 request,
because the size of the reader (even though it was known, being one of
the three common recognized types from NewRequest) was zero, and so
the HTTP Transport thought it was simply unset.

To signal explicitly-zero vs unset-zero, this CL changes NewRequest to
signal explicitly-zero by setting the Body to nil, instead of the
strings.NewReader("") or other zero-byte reader.

This CL also removes the byte sniff from the http1 Transport, like
https://golang.org/cl/31326 did for http2.

Updates #17480
Updates #17071

Change-Id: I329f02f124659bf7d8bc01e2c9951ebdd236b52a
Reviewed-on: https://go-review.googlesource.com/31445
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-19 13:35:20 +00:00
Russ Cox
4c1995f95b reflect: document DeepEqual(nil map, empty non-nil map) behavior
Fixes #16531.

Change-Id: I41ec8123f2d3fbe063fd3b09a9366e69722793e5
Reviewed-on: https://go-review.googlesource.com/31355
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-19 13:33:50 +00:00
Russ Cox
6c295a9a71 syscall: for ForkExec on Linux, always use 32-bit setgroups system call
Fixes #17092.

Change-Id: If203d802a919e00594ddc1282782fc59a083fd63
Reviewed-on: https://go-review.googlesource.com/31458
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-19 13:33:18 +00:00
Russ Cox
f2f8d58b92 reflect: update FieldByNameFunc comment
This was supposed to be in CL 31354
but was dropped due to a Git usage error.

For #16573.

Change-Id: I3d99087c8efc8cbc016c55e8365d0005f79d1b2f
Reviewed-on: https://go-review.googlesource.com/31461
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-19 13:32:51 +00:00
Russ Cox
2f7f679c79 html/template, text/template: clarify template redefinition behavior
Make two important points clearer:

 - Giving a template definition containing
   nothing but spaces has no effect.
 - Giving a template definition containing
   non-spaces can only be done once per template.

Fixes #16912.
Fixes #16913.
Fixes #17360.

Change-Id: Ie3971b83ab148b7c8bb800fe4a21579566378e3e
Reviewed-on: https://go-review.googlesource.com/31459
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-10-19 12:57:09 +00:00
Russ Cox
ae14472af9 os: clean up after test
Noted in CL 31358 after submit.

Change-Id: I76ddad9b9e27dd6a03c1c4f49153213747fe0a61
Reviewed-on: https://go-review.googlesource.com/31365
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-19 07:11:16 +00:00
Ingo Oeser
9aed16e96d regexp: avoid alloc in QuoteMeta when not quoting
Many users quote literals in regular expressions just in case.
No need to allocate then.

Note: Also added benchmarks for quoting and not quoting.

	name             old time/op    new time/op     delta
	QuoteMetaAll-4      629ns ± 6%      654ns ± 5%    +4.01%        (p=0.001 n=20+19)
	QuoteMetaNone-4    1.02µs ± 6%     0.20µs ± 0%   -80.73%        (p=0.000 n=18+20)

	name             old speed      new speed       delta
	QuoteMetaAll-4   22.3MB/s ± 6%   21.4MB/s ± 5%    -3.94%        (p=0.001 n=20+19)
	QuoteMetaNone-4  25.3MB/s ± 3%  131.5MB/s ± 0%  +419.28%        (p=0.000 n=17+19)

	name             old alloc/op   new alloc/op    delta
	QuoteMetaAll-4      64.0B ± 0%      64.0B ± 0%      ~     (all samples are equal)
	QuoteMetaNone-4     96.0B ± 0%      0.0B ±NaN%  -100.00%        (p=0.000 n=20+20)

	name             old allocs/op  new allocs/op   delta
	QuoteMetaAll-4       2.00 ± 0%       2.00 ± 0%      ~     (all samples are equal)
	QuoteMetaNone-4      2.00 ± 0%      0.00 ±NaN%  -100.00%        (p=0.000 n=20+20)

Change-Id: I38d50f463cde463115d22534f8eb849e54d899af
Reviewed-on: https://go-review.googlesource.com/31395
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-19 07:09:08 +00:00
Emmanuel Odeke
f36e1adaa2 math/big: implement Float.Scan, type assert fmt interfaces to enforce docs
Implements Float.Scan which satisfies fmt.Scanner interface.
Also enforces docs' interface implementation claims with compile time
type assertions, that is:
+ Float always implements fmt.Formatter and fmt.Scanner
+ Int always implements fmt.Formatter and fmt.Scanner
+ Rat always implements fmt.Formatter
which will ensure that the API claims are strictly matched.

Also note that Float.Scan doesn't handle ±Inf.

Fixes #17391

Change-Id: I3d3dfbe7f602066975c7a7794fe25b4c645440ce
Reviewed-on: https://go-review.googlesource.com/30723
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-19 03:25:30 +00:00
Caio Marcelo de Oliveira Filho
ead08e91f6 cmd/go, testing: indicate when no tests are run
For example, testing the current directory:

	$ go test -run XXX
	testing: warning: no tests to run
	PASS
	ok  	testing	0.013s
	$

And in a summary:

	$ go test -run XXX testing
	ok  	testing	0.013s [no tests to run]
	$

These make it easy to spot when the -run regexp hasn't matched anything
or there are no tests. Previously the message was printed in the "current directory"
case when there were no tests at all, but not for no matches, and either way
was not surfaced in the directory list summary form.

Fixes #15211.

Change-Id: I1c82a423d6bd429fb991c9ca964c9d26c96fd3c5
Reviewed-on: https://go-review.googlesource.com/22341
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2016-10-19 02:34:44 +00:00
Russ Cox
95abb5a36a cmd/go: make go test -i -o x.test actually write x.test
Fixes #17078.

Change-Id: I1dfb71f64361b575ec461ed44b0779f2d5cf45fc
Reviewed-on: https://go-review.googlesource.com/31352
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-10-19 02:31:26 +00:00
Russ Cox
e6a901ea3a cmd/go: disable SSH connection pooling to avoid git hang
Fixes #13453.
Fixes #16104.

Change-Id: I4e94f606df786af8143f8649c9afde570f346301
Reviewed-on: https://go-review.googlesource.com/31353
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-10-19 02:26:39 +00:00
Russ Cox
e05d014048 reflect: correct Type.FieldByNameFunc docs
Fixes #16573.

Change-Id: I5a26eaa8b258cb1861190f9690086725532b8a0d
Reviewed-on: https://go-review.googlesource.com/31354
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-19 01:48:40 +00:00
Hiroshi Ioka
e65bce7144 os, syscall: fix incorrect offset calculation in Readlink on windows
Current implementation of syscall.Readlink mistakenly calculates
the end offset of the PrintName field.
Also, there are some cases that the PrintName field is empty.
Instead, the CL uses SubstituteName with correct calculation.

Fixes #15978
Fixes #16145

Change-Id: If3257137141129ac1c552d003726d5b9c08bb754
Reviewed-on: https://go-review.googlesource.com/31118
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-19 01:25:18 +00:00
Russ Cox
ebf827ded7 testing: wrap long comment line
Requested in CL 31324 review.

Change-Id: Ic81410e07cce07c6f3727bc46d86b6c54c15eca0
Reviewed-on: https://go-review.googlesource.com/31410
Reviewed-by: Rob Pike <r@golang.org>
2016-10-19 01:21:21 +00:00
Russ Cox
321c312d82 os: reject Rename("old", "new") where new is a directory
Unix rejects this when new is a non-empty directory.
Other systems reject this when new is a directory, empty or not.
Make Unix reject empty directory too.

Fixes #14527.

Change-Id: Ice24b8065264c91c22cba24aa73e142386c29c87
Reviewed-on: https://go-review.googlesource.com/31358
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-19 01:21:05 +00:00
Robert Griesemer
8fbfdad281 spec: require 16 bit minimum exponent in constants rather than 32
A 16bit binary exponent permits a constant range covering roughly the range
from 7e-9865 to 7e9863 which is more than enough for any practical and
hypothetical constant arithmetic.

Furthermore, until recently cmd/compile could not handle very large exponents
correctly anyway; i.e., the chance that any real programs (but for tests that
explore corner cases) are affected are close to zero.

Finally, restricting the minimum supported range significantly reduces the
implementation complexity in an area that hardly matters in reality for new
or alternative spec-compliant implementations that don't or cannot rely on
pre-existing arbitratry precision arithmetic packages that support a 32bit
exponent range.

This is technically a language change but for the reasons mentioned above
this is unlikely to affect any real programs, and certainly not programs
compiled with the gc or gccgo compilers as they currently support up to
32bit exponents.

Fixes #13572.

Change-Id: I970f919c57fc82c0175844364cf48ea335f17d39
Reviewed-on: https://go-review.googlesource.com/17711
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-18 22:36:50 +00:00
Matthew Dempsky
3f2cb493e5 cmd/compile: handle unsafe builtins like universal builtins
Reuse the same mechanisms for handling universal builtins like len to
handle unsafe.Sizeof, etc. Allows us to drop package unsafe's export
data, and simplifies some code.

Updates #17508.

Change-Id: I620e0617c24e57e8a2d7cccd0e2de34608779656
Reviewed-on: https://go-review.googlesource.com/31433
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-18 22:34:44 +00:00
Mohit Agarwal
7eed848a17 math: speed up Gamma(+Inf)
Add special case for Gamma(+∞) which speeds it up:

benchmark            old ns/op     new ns/op     delta
BenchmarkGamma-4     14.5          7.44          -48.69%

The documentation for math.Gamma already specifies it as a special
case:

        Gamma(+Inf) = +Inf

The original C code that has been used as the reference implementation
(as mentioned in the comments in gamma.go) also treats Gamma(+∞) as a
special case:

if( x == INFINITY )
        return(x);

Change-Id: Idac36e19192b440475aec0796faa2d2c7f8abe0b
Reviewed-on: https://go-review.googlesource.com/31370
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-18 22:12:03 +00:00
Brad Fitzpatrick
97b04152bc net/http: update test to check Content-Length 0 Body more reliably
The way to send an explicitly-zero Content-Length is to set a nil Body.

Fix this test to do that, rather than relying on type sniffing.

Updates #17480
Updates #17071

Change-Id: I6a38e20f17013c88ec4ea69d73c507e4ed886947
Reviewed-on: https://go-review.googlesource.com/31434
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-10-18 21:53:31 +00:00
Quentin Smith
75fef5a0f6 cmd/go: print more env variables in "go env"
"go env" previously only printed a subset of the documented environment
variables; now it includes everything, such as GO386 and CGO_*.

This also fixes the CGO_CFLAGS environment variable to always have the
same default. According to iant@ and confirmed by testing, cgo can now
understand the default value of CGO_CFLAGS.

Fixes #17191.

Change-Id: Icf75055446dd250b6256ef1139e9ce848f4a9d3b
Reviewed-on: https://go-review.googlesource.com/31330
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Quentin Smith <quentin@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-18 20:24:45 +00:00
Dhananjay Nakrani
8b3194ac8f cmd/compile: fix code duplication in race-instrumentation
instrumentnode() accidentally copies parent's already-instrumented nodes
into child's Ninit block. This generates repeated code in race-instrumentation.
This case surfaces only when it duplicates inline-labels, because of
compile time error. In other cases, it silently generates incorrect
instrumented code. This change prevents it from doing so.

Fixes #17449.

Change-Id: Icddf2198990442166307e176b7e20aa0cf6c171c
Reviewed-on: https://go-review.googlesource.com/31317
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-18 20:11:01 +00:00
Matthew Dempsky
2b687a7df8 cmd/compile: stop treating interface methods like actual functions
Interface methods can't have function bodies, so there's no need to
process their parameter lists as variable declarations. The only
possible reason would be to check for duplicate parameter names and/or
invalid types, but we do that anyway, and have regression tests for it
(test/funcdup.go).

Change-Id: Iedb15335467caa5d872dbab829bf32ab8cf6204d
Reviewed-on: https://go-review.googlesource.com/31430
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-18 17:29:52 +00:00
Brad Fitzpatrick
2a441d3078 net/http/internal: don't block unnecessarily in ChunkedReader
Fixes #17355

Change-Id: I5390979cd0081b61a639466377faa46b4221b74a
Reviewed-on: https://go-review.googlesource.com/31329
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-18 17:26:18 +00:00
Michael Munday
430b82009c cmd/internal/obj/{ppc64,s390x}: mark functions with small stacks NOSPLIT
This change omits the stack check on ppc64 and s390x when the size of
a stack frame is less than obj.StackSmall. This is an optimization
x86 already performs.

The effect on s390x isn't huge because we were already omitting the
stack check when the frame size was 0 (it shaves about 1K from the
size of bin/go). On ppc64 however this change reduces the size of the
.text section in bin/go by 33K (1%).

Updates #13379 (for ppc64).

Change-Id: I6af0eb987646bea47fcaf0a812db3496bab0f680
Reviewed-on: https://go-review.googlesource.com/31357
Reviewed-by: David Chase <drchase@google.com>
2016-10-18 17:07:14 +00:00
David du Colombier
c1ab165fa6 net/http: enable TestTransportRemovesDeadIdleConnections on Plan 9
This issue has been fixed in CL 31390.

Fixes #15464.

Change-Id: I35e088f37bf3b544100ff131c72690bcfd788e5b
Reviewed-on: https://go-review.googlesource.com/31393
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-18 13:36:34 +00:00
David du Colombier
8a255cb85c net: enable TestCancelRequestWithChannelBeforeDo on Plan 9
This issue has been fixed in CL 31390.

Fixes #11476.

Change-Id: I6658bda2e494d3239d62c49d0bd5d34a36b744d0
Reviewed-on: https://go-review.googlesource.com/31394
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 13:31:14 +00:00
David du Colombier
0c12bdf73b net: always wake up the readers on close on Plan 9
Previously, in acceptPlan9 we set netFD.ctl to the listener's
/net/tcp/*/listen file instead of the accepted connection's
/net/tcp/*/ctl file.

In netFD.Read, we write "close" to netFD.ctl to close the
connection and wake up the readers. However, in the
case of an accepted connection, we got the error
"write /net/tcp/*/listen: inappropriate use of fd"
because the /net/tcp/*/listen doesn't handle the "close" message.

In this case, the connection wasn't closed and the readers
weren't awake.

We modified the netFD structure so that netFD.ctl represents
the accepted connection and netFD.listen represents the
listener.

Change-Id: Ie38c7dbaeaf77fe9ff7da293f09e86d1a01b3e1e
Reviewed-on: https://go-review.googlesource.com/31390
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 13:27:09 +00:00
Russ Cox
c1a1328c5f encoding/xml: add wildcard support for collecting all attributes
- Like ",any" for elements, add ",any,attr" for attributes to allow
  a mop-up field that gets any otherwise unmapped attributes.
- Map attributes to fields of type slice by extending the slice,
  just like for elements.
- Allow storing an attribute into an xml.Attr directly, to provide
  a way to record the name.

Combined, these three independent features allow

	AllAttrs []Attr `xml:",any,attr"`

to collect all attributes not otherwise spoken for in a particular struct.

Tests based on CL 16292 by Charles Weill.

Fixes #3633.

Change-Id: I2d75817f17ca8752d7df188080a407836af92611
Reviewed-on: https://go-review.googlesource.com/30946
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-10-18 12:59:41 +00:00
Russ Cox
0794dce072 bufio: read from underlying reader at most once in Read
Fixes #17059.

Change-Id: I5c7ee46604399f7dc3c3c49f964cbb1aa6c0d621
Reviewed-on: https://go-review.googlesource.com/31320
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-18 12:56:55 +00:00
David du Colombier
3d1ae4b75c net: close the connection gracefully on Plan 9
Previously, we used to write the "hangup" message to
the TCP connection control file to be able to close
a connection, while waking up the readers.

The "hangup" message closes the TCP connection with a
RST message. This is a problem when closing a connection
consecutively to a write, because the reader may not have
time to acknowledge the message before the connection is
closed, resulting in loss of data.

We use a "close" message, newly implemented in the Plan 9
kernel to be able to close a TCP connection gracefully with a FIN.

Updates #15464.

Change-Id: I2050cc72fdf7a350bc6c9128bae7d14af11e599c
Reviewed-on: https://go-review.googlesource.com/31271
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 12:56:52 +00:00
Russ Cox
a431bdc712 testing: document that Skip cannot undo Error
Fixes #16502.

Change-Id: Id8e117a724d73cd51844c06d47bbeba61f8dc827
Reviewed-on: https://go-review.googlesource.com/31324
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2016-10-18 12:56:20 +00:00
Russ Cox
1188569534 testing: fix flag usage messages
Fixes #16404.

Change-Id: Iabaeeef3eff2fff6e5ed2d6bc9ef9c2f6d1cb5e7
Reviewed-on: https://go-review.googlesource.com/31332
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-18 12:56:13 +00:00
Russ Cox
c999108723 time: revise Timer comments for Stop, Reset
The comments added for Go 1.7 are very close.
Make explicit that they only apply if the timer is
not known to have expired already.

Fixes #14038.

Change-Id: I6a38be7b2015e1571fc477e18444a8cee38aab29
Reviewed-on: https://go-review.googlesource.com/31350
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 12:55:24 +00:00
Russ Cox
427674fa0e io: clarify Pipe docs
Fixes #14139.

Change-Id: I6d2181720c38582b3d2160e94c7593a6cb4fc60f
Reviewed-on: https://go-review.googlesource.com/31321
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 12:53:56 +00:00
Russ Cox
736443c13a os/exec: allow simultaneous cmd.Wait and Write of cmd.StdinPipe
cmd.StdinPipe returns an io.WriteCloser.
It's reasonable to expect the caller not to call Write and Close simultaneously,
but there is an implicit Close in cmd.Wait that's not obvious.
We already synchronize the implicit Close in cmd.Wait against
any explicit Close from the caller. Also synchronize that implicit
Close against any explicit Write from the caller.

Fixes #9307.

Change-Id: I8561e9369d6e5ac88dfbca1175549f6dfa04b8ac
Reviewed-on: https://go-review.googlesource.com/31148
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-18 12:48:03 +00:00
Russ Cox
5fbf35dc3f time: be consistent about representation of UTC location in Time struct
In the zero Time, the (not user visible) nil *Location indicates UTC.
In the result of t.UTC() and other ways to create times in specific
zones, UTC is indicated by a non-nil *Location, specifically &utcLoc.
This creates a representation ambiguity exposed by comparison with ==
or reflect.DeepEqual or the like.

Change time.Time representation to use only nil, never &utcLoc,
to represent UTC. This eliminates the ambiguity.

Fixes #15716.

Change-Id: I7dcc2c20ce6b073e1daae323d3e49d17d1d52802
Reviewed-on: https://go-review.googlesource.com/31144
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 12:42:46 +00:00
Mikio Hara
79c036238d net: update docs on network interface API
This change documents that the InterfaceAddrs function is less usable on
multi-homed IP nodes because of the lack of network interface
identification information.

Also updates documentation on exposed network interface API.

Fixes #14518.

Change-Id: I5e86606f8019ab475eb5d385bd797b052cba395d
Reviewed-on: https://go-review.googlesource.com/31371
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 11:46:27 +00:00
Daniel Theophanes
2a85578b0e database/sql: support returning query database types
Creates a ColumnType structure that can be extended in to future.
Allow drivers to implement what makes sense for the database.

Fixes #16652

Change-Id: Ieb1fd64eac1460107b1d3474eba5201fa300a4ec
Reviewed-on: https://go-review.googlesource.com/29961
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 10:52:57 +00:00
Martin Möhrmann
2ecaaf18f9 fmt: always handle special methods if print operand is a reflect.Value
Check for and call the special printing and format methods such as String
at printing depth 0 when printing the concrete value of a reflect.Value.

Fixes: #16015

Change-Id: I23bd2927255b60924e5558321e98dd4a95e11c4c
Reviewed-on: https://go-review.googlesource.com/30753
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-18 10:50:26 +00:00
Brad Fitzpatrick
faf882d1d4 net/http: make Server Handler's Request.Context be done on conn errors
This CL changes how the http1 Server reads from the client.

The goal of this change is to make the Request.Context given to Server
Handlers become done when the TCP connection dies (has seen any read
or write error). I didn't finish that for Go 1.7 when Context was
added to http package.

We can't notice the peer disconnect unless we're blocked in a Read
call, though, and previously we were only doing read calls as needed,
when reading the body or the next request. One exception to that was
the old pre-context CloseNotifier mechanism.

The implementation of CloseNotifier has always been tricky. The past
few releases have contained the complexity and moved the
reading-from-TCP-conn logic into the "connReader" type. This CL
extends connReader to make sure that it's always blocked in a Read
call, at least once the request body has been fully consumed.

In the process, this deletes all the old CloseNotify code and unifies
it with the context cancelation code. The two notification mechanisms
are nearly identical, except the CloseNotify path always notifies on
the arrival of pipelined HTTP/1 requests. We might want to change that
in a subsequent commit. I left a TODO for that. For now there's no
change in behavior except that the context now cancels as it was
supposed to.

As a bonus that fell out for free, a Handler can now use CloseNotifier
and Hijack together in the same request now.

Fixes #15224 (make http1 Server always in a Read, like http2)
Fixes #15927 (cancel context when underlying connection closes)
Updates #9763 (CloseNotifier + Hijack)

Change-Id: I972cf6ecbab7f1230efe8cc971e89f8e6e56196b
Reviewed-on: https://go-review.googlesource.com/31173
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-18 06:54:47 +00:00
Adam Langley
35e5fd0c4d crypto/tls: enable ChaCha20-Poly1305 cipher suites by default.
This change enables the ChaCha20-Poly1305 cipher suites by default. This
changes the default ClientHello and thus requires updating all the
tests.

Change-Id: I6683a2647caaff4a11f9e932babb6f07912cad94
Reviewed-on: https://go-review.googlesource.com/30958
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 06:54:30 +00:00
Adam Langley
cff3e7587a crypto/tls: add Config.GetConfigForClient
GetConfigForClient allows the tls.Config to be updated on a per-client
basis.

Fixes #16066.
Fixes #15707.
Fixes #15699.

Change-Id: I2c675a443d557f969441226729f98502b38901ea
Reviewed-on: https://go-review.googlesource.com/30790
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 06:44:05 +00:00
Russ Cox
7e2bf952a9 net/url: add PathEscape, PathUnescape
Fixes #13737.

Change-Id: Ib655dbf06f44709f687f8a2410c80f31e4075f13
Reviewed-on: https://go-review.googlesource.com/31322
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-18 06:34:58 +00:00
Russ Cox
59dae58174 net/url: document and add example for ParseQuery("x")
Fixes #16460.

Change-Id: Ie9d5f725d2d7e8210ab6f7604a5a05fc49f707de
Reviewed-on: https://go-review.googlesource.com/31331
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 06:19:46 +00:00
Rob Pike
ac1108bdcb fmt: fix documention for %#v on uints
It's the same as %#x not %x.

Just a documentation change; tests already cover it.

Fixes #17322

Change-Id: Ia9db229f781f9042ac5c0bb824e3d7a26fb74ec5
Reviewed-on: https://go-review.googlesource.com/31254
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-18 06:14:31 +00:00
Alberto Donizetti
f6cdfc7987 math/big: add benchmarks for big.Float String
In addition to the DecimalConversion benchmark, that exercises the
String method of the internal decimal type on a range of small shifts,
add a few benchmarks for the big.Float String method. They can be used
to obtain more realistic data on the real-world performance of
big.Float printing.

Change-Id: I7ada324e7603cb1ce7492ccaf3382db0096223ba
Reviewed-on: https://go-review.googlesource.com/31275
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-18 05:54:35 +00:00
Russ Cox
57666c3fe8 test: avoid matching file names in errcheck
Fixes #17030.

Change-Id: Ic7f237ac7553ae0176929056e64b01667ed59066
Reviewed-on: https://go-review.googlesource.com/31351
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 05:32:37 +00:00