summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* net: fix writev tests on AndroidElias Naur2016-12-011-1/+1
| | | | | | Change-Id: Iacced25363f54ee2cc1e00a71605dba7fb447162 Reviewed-on: https://go-review.googlesource.com/33772 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/compile: generate frame pointers for otherwise frameless functionsKeith Randall2016-12-014-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | func f() { g() } We mistakenly don't add a frame pointer for f. This means f isn't seen when walking the frame pointer linked list. That matters for kernel-gathered profiles, and is an impediment for issues like #16638. To fix, allocate a stack frame even for otherwise frameless functions like f. It is a bit tricky because we need to avoid some runtime internals that really, really don't want one. No test at the moment, as only kernel CPU profiles would catch it. Tests will come with the implementation of #16638. Fixes #18103 Change-Id: I411206cc9de4c8fdd265bee2e4fa61d161ad1847 Reviewed-on: https://go-review.googlesource.com/33754 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
* crypto/x509: read Darwin trust settings for root CAsQuentin Smith2016-12-013-11/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Darwin separately stores bits indicating whether a root certificate should be trusted; this changes Go to read and use those when initializing SystemCertPool. Unfortunately, the trust API is very slow. To avoid a delay of up to 0.5s in initializing the system cert pool, we assume that the trust settings found in kSecTrustSettingsDomainSystem will always indicate trust. (That is, all root certs Apple distributes are trusted.) This is not guaranteed by the API but is true in practice. In the non-cgo codepath, we do not have that benefit, so we must check the trust status of every certificate. This causes about 0.5s of delay in initializing the SystemCertPool. On OS X 10.11 and older, the "security" command requires a certificate to be provided in a file and not on stdin, so the non-cgo codepath creates temporary files for each certificate, further slowing initialization. Updates #18141. Change-Id: If681c514047afe5e1a68de6c9d40ceabbce54755 Reviewed-on: https://go-review.googlesource.com/33721 Run-TryBot: Quentin Smith <quentin@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/compile: do not inline functions marked cgo_unsafe_argsDavid Lazar2016-12-011-0/+6
| | | | | | | | | | Now the net tests pass with -gcflags '-l=4'. Fixes #18125. Change-Id: I4e3a46eb0cb3a93b203e74f5bc99c5822331f535 Reviewed-on: https://go-review.googlesource.com/33722 Reviewed-by: Keith Randall <khr@golang.org>
* cmd/objdump: copy gosym.PCValue into internal packageKeith Randall2016-12-012-9/+49
| | | | | | | | | | ... so we don't have to export gosym.PCValue. Change-Id: Ie8f196d5e5ab63e3e69d1d7b4bfbbf32b7b5e4f5 Reviewed-on: https://go-review.googlesource.com/33791 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/go: hide the "TERM" environment variable from "go bug"Mohit Agarwal2016-12-011-1/+5
| | | | | | | | | | Fixes #18128 Change-Id: I5530c9d774a1e398cd759a05bbf308e6e42f0007 Reviewed-on: https://go-review.googlesource.com/33810 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http: clarify Request.Context's lifetimeBrad Fitzpatrick2016-12-011-2/+2
| | | | | | | | | | | | Reverts https://golang.org/cl/23672 and tweaks the text to clarify HTTP/2 request cancelations also cancel the context (not just closing the TCP conn). Fixes #18143 Change-Id: I9f838e09b906d455c98f676e5bc5559f8f7ecb17 Reviewed-on: https://go-review.googlesource.com/33769 Reviewed-by: Chris Broadfoot <cbro@golang.org>
* database/sql: document expectations for named parametersDaniel Theophanes2016-12-015-9/+35
| | | | | | | | | | Require parameter names to not begin with a symbol. Change-Id: I5dfe9d4e181f0daf71dad2f395aca41c68678cbe Reviewed-on: https://go-review.googlesource.com/33493 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* runtime: fix incorrect comment about bitvector layoutAustin Clements2016-12-011-1/+1
| | | | | | | | | Commit 303b69fe packed bitvectors more tightly, but missed a comment describing their old layout. Update that comment. Change-Id: I095ccb01f245197054252545f37b40605a550dec Reviewed-on: https://go-review.googlesource.com/33718 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* Revert "runtime: handle SIGPIPE in c-archive and c-shared programs"Elias Naur2016-12-012-15/+8
| | | | | | | | | | | | This reverts commit d24b57a6a1a3530e590b7c0a72dc78043e198630. Reason for revert: Further complications arised (issue 18100). We'll try again in Go 1.9. Change-Id: I5ca93d2643a4be877dd9c2d8df3359718440f02f Reviewed-on: https://go-review.googlesource.com/33770 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Minux Ma <minux@golang.org> Run-TryBot: Minux Ma <minux@golang.org>
* cmd/dist: add -check-armv6k command to check for ARMv6KShenghou Ma2016-12-015-0/+27
| | | | | | | | | | | | | so that our release note can reference a simple command to check if the processor implements ARMv6K or not. Updates #17082. Change-Id: I9ca52051e5517394a7cd6b778fb822c3ee435f84 Reviewed-on: https://go-review.googlesource.com/33686 Run-TryBot: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* sort: add Slice exampleBrad Fitzpatrick2016-12-011-0/+19
| | | | | | | | Change-Id: I34ba4eaf1d232b639998ad3bbb0d075dd097722b Reviewed-on: https://go-review.googlesource.com/33763 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dominik Honnef <dominik@honnef.co>
* api: promote next.txt to go1.8.txt, update go toolgo1.8beta1Chris Broadfoot2016-12-011-1/+1
| | | | | | Change-Id: I37f2893ce14009efe095aac3bc811d650c66bf2a Reviewed-on: https://go-review.googlesource.com/33761 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/cgo: fix cgo checking when fetching errno valueIan Lance Taylor2016-12-011-18/+33
| | | | | | | | | | Fixes #18126. Change-Id: I7ae090945ef203673b06eb94817cc5c894b5eadc Reviewed-on: https://go-review.googlesource.com/33752 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* encoding/binary: document the new bool supportBrad Fitzpatrick2016-12-011-1/+4
| | | | | | | | Updates #16856 Change-Id: I57af6b0c0d5ecdaf19cf6f969b05ec9ec03058f1 Reviewed-on: https://go-review.googlesource.com/33756 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go: document GOPATH default exceptionRuss Cox2016-11-302-2/+4
| | | | | | | | | | Doesn't get defaulted if $HOME/go is a GOROOT. Change-Id: I6ac8211a74029e4ad70a50f6e7884a039a27ab05 Reviewed-on: https://go-review.googlesource.com/33720 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* doc, cmd/go: adjust documentation for default GOPATHRuss Cox2016-11-302-12/+16
| | | | | | | | | | | Replaces CL 33356. Fixes #17262. Change-Id: Idfb2343e90771775e51a66c63760f458737a288c Reviewed-on: https://go-review.googlesource.com/33730 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/compile: generate code that type checks when inlining variadic functionsDavid Lazar2016-11-301-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a bug in -l=3 or higher. To inline a variadic function, the compiler generates code that constructs a slice of arguments for the variadic parameter. Consider the function func Foo(xs ...string) and the call Foo("hello", "world"). To inline the call to Foo, the compiler used to generate xs := [2]string{"hello", "world"}[:] which doesn't type check: invalid operation [2]string literal[:] (slice of unaddressable value). Now, the compiler generates xs := []string{"hello", "world"} which does type check. Fixes #18116. Change-Id: I0ee531ef2e6cc276db6fb12602b25a46d6d5db21 Reviewed-on: https://go-review.googlesource.com/33671 Reviewed-by: Keith Randall <khr@golang.org>
* database/sql: deflake query cancel testsDaniel Theophanes2016-11-302-5/+26
| | | | | | | | | | | | | Rather then using a sleep in the fake DB, go to a channel select and wait for the context to be done. Fixes #18115 Change-Id: I6bc3a29db58c568d0a7ea06c2a354c18c9e798b2 Reviewed-on: https://go-review.googlesource.com/33712 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* runtime: fix undead arguments in cgocallAustin Clements2016-11-301-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From the garbage collector's perspective, time can move backwards in cgocall. However, in the midst of this time warp, the pointer arguments to cgocall can go from dead back to live. If a stack growth happens while they're dead and then a GC happens when they become live again, GC can crash with a bad heap pointer. Specifically, the sequence that leads to a panic is: 1. cgocall calls entersyscall, which saves the PC and SP of its call site in cgocall. Call this PC/SP "X". At "X" both pointer arguments are live. 2. cgocall calls asmcgocall. Call the PC/SP of this call "Y". At "Y" neither pointer argument is live. 3. asmcgocall calls the C code, which eventually calls back into the Go code. 4. cgocallbackg remembers the saved PC/SP "X" in some local variables, calls exitsyscall, and then calls cgocallbackg1. 5. The Go code causes a stack growth. This stack unwind sees PC/SP "Y" in the cgocall frame. Since the arguments are dead at "Y", they are not adjusted. 6. The Go code returns to cgocallbackg1, which calls reentersyscall with the recorded saved PC/SP "X", so "X" gets stashed back into gp.syscallpc/sp. 7. GC scans the stack. It sees there's a saved syscall PC/SP, so it starts the traceback at PC/SP "X". At "X" the arguments are considered live, so it scans them, but since they weren't adjusted, the pointers are bad, so it panics. This issue started as of commit ca4089ad, when the compiler stopped marking arguments as live for the whole function. Since this is a variable liveness issue, fix it by adding KeepAlive calls that keep the arguments live across this whole time warp. The existing issue7978 test has all of the infrastructure for testing this except that it's currently up to chance whether a stack growth happens in the callback (it currently only happens on the linux-amd64-noopt builder, for example). Update this test to force a stack growth, which causes it to fail reliably without this fix. Fixes #17785. Change-Id: If706963819ee7814e6705693247bcb97a6f7adb8 Reviewed-on: https://go-review.googlesource.com/33710 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
* runtime: use standard comment style in cgocallAustin Clements2016-11-301-15/+11
| | | | | | | Change-Id: I9f2c2da4aa512729ae40562b06601da95ba50d6f Reviewed-on: https://go-review.googlesource.com/33689 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
* database/sql: rename NamedParam to NamedArg and Param to NamedDaniel Theophanes2016-11-303-12/+23
| | | | | | | | | | | | Be consistent with the argument names already provided. Also parameter is the variable, argument is the value. Fixes #18099 Change-Id: Idb3f4e9ffc214036c721ddb4f614ec6c95bb7778 Reviewed-on: https://go-review.googlesource.com/33660 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* net/http: document how headers are forwarded by ClientJoe Tsai2016-11-301-2/+27
| | | | | | | | Fixes #18096 Change-Id: I22e1abb75dc19c4d1985b6857c79a81b9db5a76c Reviewed-on: https://go-review.googlesource.com/33670 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: fix test TestServeMuxHandlerRedirectsShenghou Ma2016-11-301-2/+2
| | | | | | | | | | | | | | The code was intended to test that mux handler should redirect at most once, but the added loop condition defeated that. Remove the loop condition and document the intention better. Fixes #18068. Change-Id: I2a4ea041eae27168b45a09aa46e740ac03921594 Reviewed-on: https://go-review.googlesource.com/33654 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: remove logging on bad client requestsKenny Grant2016-11-301-2/+0
| | | | | | | | | | As discussed in #18095 the server should not log for bad user input. Change-Id: I628a796926eff3a971e5b04abec17ea377c3f9b7 Reviewed-on: https://go-review.googlesource.com/33617 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/compile/internal/gc: document variables and functionsKevin Burke2016-11-303-0/+10
| | | | | | Change-Id: I01b2278eb50585331b8ff7ff5e3c1f9c5ba52b63 Reviewed-on: https://go-review.googlesource.com/33156 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* go/ast: fix doc string for ast.GenDeclRobert Griesemer2016-11-291-1/+1
| | | | | | | | Fixes #18109. Change-Id: I5e3a44422794b7bae7741523fb7cacb6ba147af7 Reviewed-on: https://go-review.googlesource.com/33669 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net: expand nss myhostname fallback detectionDan Peterson2016-11-293-59/+101
| | | | | | | | | | | | | Expand myhostname fallback detection to properly detect the local hostname in addition to other supported special names and suffixes. Fixes #17967 Change-Id: I1fe141fd9838b25886c08b6f2fd325e58be60457 Reviewed-on: https://go-review.googlesource.com/33550 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* crypto/tls: update CBC Lucky13 warning a bitBrad Fitzpatrick2016-11-291-1/+1
| | | | | | | | | | Some countermeasures were implemented in https://golang.org/cl/18130 Updates #13385 Change-Id: I723e1e3be0fa6d13767b65b145d90c89e92b2774 Reviewed-on: https://go-review.googlesource.com/33665 Reviewed-by: Adam Langley <agl@golang.org>
* cmd/compile/internal/syntax: remove unused node fieldRobert Griesemer2016-11-291-1/+2
| | | | | | | | | | | | The doc field is not yet used - remove it for now (we may end up with a different solution for 1.9). This reduces memory consumption for parsing all of std lib by about 40MB and makes parsing slightly faster. Change-Id: Iafb00b9c7f1be9c66fdfb29096d3da5049b2fcf5 Reviewed-on: https://go-review.googlesource.com/33661 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* database/sql: do not bypass the driver locks with Context methodsDaniel Theophanes2016-11-295-217/+242
| | | | | | | | | | | | | | | | | When context methods were initially added it was attempted to unify behavior between drivers without Context methods and those with Context methods to always return right away when the Context expired. However in doing so the driver call could be executed outside of the scope of the driver connection lock and thus bypassing thread safety. The new behavior waits until the driver operation is complete. It then checks to see if the context has expired and if so returns that error. Change-Id: I4a5c7c3263420c57778f36a5ed6fa0ef8cb32b20 Reviewed-on: https://go-review.googlesource.com/32422 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/go: report position info in package errorsDhananjay Nakrani2016-11-292-21/+18
| | | | | | | | | | | | Also refactor common position filling code into a function. Fixes #18011 Change-Id: I76528626da67a7309193fa92af1e361c8e2fcf84 Reviewed-on: https://go-review.googlesource.com/33631 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* internal/pprof/profile: parse mutex profile including commentsHana Kim2016-11-292-26/+95
| | | | | | | | | | | Skip lines if they are empty or starting with "#" which are valid legacy pprof output format. Fixes #18025 Change-Id: I7aee439171496932637b8ae3188700911f569b16 Reviewed-on: https://go-review.googlesource.com/33454 Reviewed-by: Peter Weinberger <pjw@google.com>
* net/http/httptest: fix typo in doc commentMichal Bohuslávek2016-11-291-1/+1
| | | | | | Change-Id: I89f276b32015882437e128814573343a4ca53569 Reviewed-on: https://go-review.googlesource.com/33615 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/compile: don't panic on syntax error in select statementRobert Griesemer2016-11-291-17/+12
| | | | | | | | | | Fixes #18092. Change-Id: I54e2da2e0f168c068f5e4a1b22ba508d78259168 Reviewed-on: https://go-review.googlesource.com/33658 TryBot-Result: Gobot Gobot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* runtime: fall back to /proc/self/auxv in Android libsAustin Clements2016-11-294-28/+37
| | | | | | | | | | | | | | | | | | | Android's libc doesn't provide access to auxv, so currently the Go runtime synthesizes a fake, minimal auxv when loaded as a library on Android. This used to be sufficient, but now we depend on auxv to retrieve the system physical page size and panic if we can't retrieve it. Fix this by falling back to reading auxv from /proc/self/auxv if the loader-provided auxv is empty and removing the synthetic auxv vectors. Fixes #18041. Change-Id: Ia2ec2c764a6609331494a5d359032c56cbb83482 Reviewed-on: https://go-review.googlesource.com/33652 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
* runtime: extract Linux auxv handlingAustin Clements2016-11-291-0/+4
| | | | | | | | | | | | | This refactoring is in preparation for handling auxv differently in Android shared libraries. Updates #18041. Change-Id: If0458a309f9c804e7abd0a58b5a224d89f8da257 Reviewed-on: https://go-review.googlesource.com/33651 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
* cmd/link: handle STT_COMMON symbolsIan Lance Taylor2016-11-291-3/+5
| | | | | | | | | | | | | | | | | | | | Tested by running GOTRACEBACK=2 CGO_CFLAGS="-Wa,--elf-stt-common=yes" go test -ldflags=-linkmode=internal in misc/cgo/test. That failed before this CL, succeeded after. I don't think it's worth doing that as a regular test, though, especially since only recent versions of the GNU binutils support the --elf-stt-common option. Fixes #18088. Change-Id: I893d86181faee217b1504c054b0ed3f7c8d977d3 Reviewed-on: https://go-review.googlesource.com/33653 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* os: fix handling of Windows Unicode console input and ^ZRuss Cox2016-11-293-171/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Go 1.5 worked with Unicode console input but not ^Z. Go 1.6 did not work with Unicode console input but did handle one ^Z case. Go 1.7 did not work with Unicode console input but did handle one ^Z case. The intent of this CL is for Go 1.8 to work with Unicode console input and also handle all ^Z cases. Here's a simple test program for reading from the console. It prints a "> " prompt, calls read, prints what it gets, and repeats. package main import ( "fmt" "os" ) func main() { p := make([]byte, 100) fmt.Printf("> ") for { n, err := os.Stdin.Read(p) fmt.Printf("[%d %q %v]\n> ", n, p[:n], err) } } On Unix, typing a ^D produces a break in the input stream. If the ^D is at the beginning of a line, then the 0 bytes returned appear as an io.EOF: $ go run /tmp/x.go > hello [6 "hello\n" <nil>] > hello^D[5 "hello" <nil>] > ^D[0 "" EOF] > ^D[0 "" EOF] > hello^Dworld [5 "hello" <nil>] > [6 "world\n" <nil>] > On Windows, the EOF character is ^Z, not ^D, and there has been a long-standing problem that in Go programs, ^Z on Windows does not behave in the expected way, namely like ^D on Unix. Instead, the ^Z come through as literal ^Z characters: C:\>c:\go1.5.4\bin\go run x.go > ^Z [3 "\x1a\r\n" <nil>] > hello^Zworld [13 "hello\x1aworld\r\n" <nil>] > CL 4310 attempted to fix this bug, then known as #6303, by changing the use of ReadConsole to ReadFile. This CL was released as part of Go 1.6 and did fix the case of a ^Z by itself, but not as part of a larger input: C:\>c:\go1.6.3\bin\go run x.go > ^Z [0 "" EOF] > hello^Zworld [13 "hello\x1aworld\r\n" <nil>] > So the fix was incomplete. Worse, the fix broke Unicode console input. ReadFile does not handle Unicode console input correctly. To handle Unicode correctly, programs must use ReadConsole. Early versions of Go used ReadFile to read the console, leading to incorrect Unicode handling, which was filed as #4760 and fixed in CL 7312053, which switched to ReadConsole and was released as part of Go 1.1 and still worked as of Go 1.5: C:\>c:\go1.5.4\bin\go run x.go > hello [7 "hello\r\n" <nil>] > hello world™ [16 "hello world™\r\n" <nil>] > But in Go 1.6: C:\>c:\go1.6.3\bin\go run x.go > hello [7 "hello\r\n" <nil>] > hello world™ [0 "" EOF] > That is, changing back to ReadFile in Go 1.6 reintroduced #4760, which has been refiled as #17097. (We have no automated test for this because we don't know how to simulate console input in a test: it appears that one must actually type at a keyboard to use the real APIs. This CL at least adds a comment warning not to reintroduce ReadFile again.) CL 29493 attempted to fix #17097, but it was not a complete fix: the hello world™ example above still fails, as does Shift-JIS input, which was filed as #17939. CL 29493 also broke ^Z handling, which was filed as #17427. This CL attempts the never before successfully performed trick of simultaneously fixing Unicode console input and ^Z handling. It changes the console input to use ReadConsole again, as in Go 1.5, which seemed to work for all known Unicode input. Then it adds explicit handling of ^Z in the input stream. (In the case where standard input is a redirected file, ^Z processing should not happen, and it does not, because this code path is only invoked when standard input is the console.) With this CL: C:\>go run x.go > hello [7 "hello\r\n" <nil>] > hello world™ [16 "hello world™\r\n" <nil>] > ^Z [0 "" EOF] > [2 "\r\n" <nil>] > hello^Zworld [5 "hello" <nil>] > [0 "" EOF] > [7 "world\r\n" <nil>] This almost matches Unix: $ go run /tmp/x.go > hello [6 "hello\n" <nil>] > hello world™ [15 "hello world™\n" <nil>] > ^D [0 "" EOF] > [1 "\n" <nil>] > hello^Dworld [5 "hello" <nil>] > [6 "world\n" <nil>] > The difference is in the handling of hello^Dworld / hello^Zworld. On Unix, hello^Dworld terminates the read of hello but does not result in a zero-length read between reading hello and world. This is dictated by the tty driver, not any special Go code. On Windows, in this CL, hello^Zworld inserts a zero length read result between hello and world, which is treated as an interior EOF. This is implemented by the Go code in this CL, but it matches the handling of ^Z on the console in other programs: C:\>copy con x.txt hello^Zworld 1 file(s) copied. C:\>type x.txt hello C:\> A natural question is how to test all this. As noted above, we don't know how to write automated tests using the actual Windows console. CL 29493 introduced the idea of substituting a different syscall.ReadFile implementation for testing; this CL continues that idea but substituting for syscall.ReadConsole instead. To avoid the regression of putting ReadFile back, this CL adds a comment warning against that. Fixes #17427. Fixes #17939. Change-Id: Ibaabd0ceb2d7af501d44ac66d53f64aba3944142 Reviewed-on: https://go-review.googlesource.com/33451 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Quentin Smith <quentin@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* os: Executable can use /proc/self/exe on androidDavid Crawshaw2016-11-291-1/+1
| | | | | | | | | | Fixes the os test on the Android builder. Change-Id: Ibb9db712156a620fcccf515e035475c5e2f535a5 Reviewed-on: https://go-review.googlesource.com/33650 Run-TryBot: David Crawshaw <crawshaw@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http, net/http/httptest: cross-reference the two NewRequest funcsBrad Fitzpatrick2016-11-282-5/+8
| | | | | | | | Updates #18082 Change-Id: I2e65b115b809c1e1bf813f538989d1a1f96b2876 Reviewed-on: https://go-review.googlesource.com/33636 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* internal/pprof: don't discard allocations called by reflect.CallIan Lance Taylor2016-11-282-6/+25
| | | | | | | | | | | | | | | The pprof code discards all heap allocations made by runtime routines. This caused it to discard heap allocations made by functions called by reflect.Call, as the calls are made via the functions `runtime.call32`, `runtime.call64`, etc. Fix the profiler to retain these heap allocations. Fixes #18077. Change-Id: I8962d552f1d0b70fc7e6f7b2dbae8d5bdefb0735 Reviewed-on: https://go-review.googlesource.com/33635 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: document restrictions on ETag as expected by ServeContentJoe Tsai2016-11-281-2/+2
| | | | | | | | | | Fixes #18054 Change-Id: I6773943a95b92eebd7e347f8f7a80843b4827243 Reviewed-on: https://go-review.googlesource.com/33630 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net: document that Header.Get key is case insensitiveKaviraj2016-11-283-3/+11
| | | | | | | | | | | Document that key in Header.Get(key) is case insensitive in http.Header, mail.Header, textproto.Header. Fixes #18019 Change-Id: Iba7932491e02e555190b6fce053088b580a853ef Reviewed-on: https://go-review.googlesource.com/33530 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/asm: fix parsing of the s390x instructions VSTE{G,F,H,B}Michael Munday2016-11-282-1/+6
| | | | | | | | | | | | | | | The element index needs to be placed in From3. Before this CL it was impossible to write a VSTE instruction that could be successfully parsed, so this won't affect existing assembly code. Fixes #18075. Change-Id: I5b71be4c6632b1d5a30820a529122f96fd1bc864 Reviewed-on: https://go-review.googlesource.com/33584 Run-TryBot: Michael Munday <munday@ca.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bill O'Farrell <billotosyr@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* net: add missing comma on BUGS section for consistencyMikio Hara2016-11-281-2/+2
| | | | | | | | Change-Id: Ic96fb52f37257e06e77cc08da5c73ea6f9ff158c Reviewed-on: https://go-review.googlesource.com/33592 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net: update documentation on Conn and PacketConnJoe Tsai2016-11-261-14/+26
| | | | | | | | Fixes #17982 Change-Id: I4884a6b57905420ac0e37210c411de98c582de1d Reviewed-on: https://go-review.googlesource.com/33473 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* testing: comment out flag.Parse from exampleDaniel Martí2016-11-251-1/+1
| | | | | | | | | | | | | | | | | | The TestMain docs explain that flag.Parse() should be called if TestMain itself depends on command-line flags. The issue here is that the example implementation does not use any flags, and thus the flag.Parse call is unnecessary. This leads to people who use this example as a starting point for their own implementations to forget that the call is not necessary in most cases. Comment it out instead of removing the line to keep it as a reminder, as suggested by Minux Ma. Change-Id: I6ffc5413e7036366ae3cf0f069b7065e832a3b45 Reviewed-on: https://go-review.googlesource.com/33273 Reviewed-by: Minux Ma <minux@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* database/sql: force users of NamedParam to name struct literals fieldsBrad Fitzpatrick2016-11-241-0/+2
| | | | | | | | | | | Or they can use sql.Param instead. Change-Id: Icf21dbcc87170635c3f5d3f49736429a37abe9da Reviewed-on: https://go-review.googlesource.com/33576 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Theophanes <kardianos@gmail.com> Reviewed-by: Minux Ma <minux@golang.org>
* net/http: fix receiver for Server.Shutdown and Server.CloseDan Peterson2016-11-241-15/+15
| | | | | | | | Change-Id: Ia27ca728bafcf20d001b477787b21d16ae12960d Reviewed-on: https://go-review.googlesource.com/33552 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>