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

15099 Commits

Author SHA1 Message Date
Kyle Lemons
9bfd3c3937 testing: add AllocsPerRun
This CL also replaces similar loops in other stdlib
package tests with calls to AllocsPerRun.

Fixes #4461.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7002055
2013-02-02 22:52:29 -05:00
Shenghou Ma
f418c505d0 lib9/main.c: don't show the crash dialog on windows
Fixes #3202. (Or rather, work around issue 3202)

R=alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/7202053
2013-02-03 06:11:25 +08:00
Russ Cox
18178fd138 cmd/go: run examples in source order, not name order
Add Order field to doc.Example and write doc comments there.

Fixes #4662.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7229071
2013-02-02 16:26:12 -05:00
Ian Lance Taylor
e5ea2d5335 runtime: fix windows build
Fixes #4743.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7284044
2013-02-02 11:41:04 -08:00
Shenghou Ma
dcf16bd83d syscall: (*Proc).Call should return nil error when no error occurs
Fixes #4686.

R=alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/7174047
2013-02-03 01:42:17 +08:00
Shenghou Ma
8047e8e95a src: add race.bat
R=golang-dev, dave, alex.brainman
CC=golang-dev
https://golang.org/cl/7133064
2013-02-03 00:49:37 +08:00
Daniel Morsing
5ea52a4d91 cmg/gc: Fix evaluation order of map indexing during multiple assignments
Fixes #4620.

R=rsc
CC=golang-dev
https://golang.org/cl/7241051
2013-02-02 12:39:04 +01:00
Russ Cox
8931306389 cmd/gc: reject non-Go constants
Expressions involving nil, even if they can be evaluated
at compile time, do not count as Go constants and cannot
be used in const initializers.

Fixes #4673.
Fixes #4680.

R=ken2
CC=golang-dev
https://golang.org/cl/7278043
2013-02-01 23:10:02 -05:00
Russ Cox
f607c479ea cmd/gc: silence redundant error prints for misuse of [...]int
Fixes #4452.

R=ken2
CC=golang-dev
https://golang.org/cl/7241065
2013-02-01 21:21:27 -05:00
Russ Cox
e2711cb202 cmd/gc: put 'not used' message on correct line
Fixes #4663.

R=ken2
CC=golang-dev
https://golang.org/cl/7235081
2013-02-01 21:13:41 -05:00
Russ Cox
79a16a3b70 cmd/gc: clearer error for defer/go of conversion or invalid function call
Fixes #4654.

R=ken2
CC=golang-dev
https://golang.org/cl/7229072
2013-02-01 21:02:15 -05:00
Russ Cox
b396d1143b reflect: explain StructField.Anonymous field as 'embedded'
The spec mostly uses the term embedded.
It's too late to change the field name but at least fix the docs.

Fixes #4514.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7235080
2013-02-01 21:01:46 -05:00
Russ Cox
2cb8dcea5c testing: SkipNow, FailNow must be called from test goroutine
Impossible for us to check (without sleazily reaching into the
runtime) but at least document it.

Fixes #3800.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7268043
2013-02-01 21:01:32 -05:00
Alex Brainman
6d175e243a net: use windows GetAddrInfoW in LookupPort when possible
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7252045
2013-01-18 17:05:04 +11:00
Elias Naur
44cf814d50 runtime, cmd/ld: make code more position-independent
Change the stack unwinding code to compensate for the dynamic
relocation of symbols.
Change the gc instruction GC_CALL to use a relative offset instead of
an absolute address.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7248048
2013-02-01 11:24:49 -08:00
Robert Daniel Kortschak
11d16dc535 reflect: document that Value.Slice panics on an unaddressable array.
Fixes #4736.

R=rsc
CC=golang-dev
https://golang.org/cl/7239045
2013-02-01 10:02:23 -08:00
Brad Fitzpatrick
2ccd4e9f87 sort: delete now-duplicate example, fix build
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7220075
2013-02-01 09:08:25 -08:00
Miek Gieben
d4cfe28885 sort: add Reverse as a function
This updates: https://golang.org/cl/6909059/
Fixes #4511.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6932054
2013-02-01 08:44:45 -08:00
Brad Fitzpatrick
e515d80d5d bytes, strings: add TrimPrefix and TrimSuffix
Everybody either gets confused and thinks this is
TrimLeft/TrimRight or does this by hand which gets
repetitive looking.

R=rsc, kevlar
CC=golang-dev
https://golang.org/cl/7239044
2013-02-01 08:41:25 -08:00
Elias Naur
fe14ee52cc cmd/6c, cmd/6g: add flag to support large-model code generation
Added the -pic flag to 6c and 6g to avoid assembler instructions that
cannot use RIP-relative adressing. This is needed to support the -shared mode
in 6l.

See also:
https://golang.org/cl/6926049
https://golang.org/cl/6822078

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7064048
2013-02-01 08:35:33 -08:00
Russ Cox
b0a29f393b runtime: cgo-related fixes
* Separate internal and external LockOSThread, for cgo safety.
* Show goroutine that made faulting cgo call.
* Never start a panic due to a signal caused by a cgo call.

Fixes #3774.
Fixes #3775.
Fixes #3797.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7228081
2013-02-01 08:34:41 -08:00
Russ Cox
32a6097fde cmd/go: clean cgo compiler errors
Cut out temporary cgo file in error message.
Show C.foo instead of _Ctype_foo.

Before:
x.go:20[/var/folders/00/05_b8000h01000cxqpysvccm000n9d/T/go-build242036121/command-line-arguments/_obj/x.cgo1.go:19]: cannot use tv.Usec (type int32) as type _Ctype___darwin_suseconds_t in assignment

After:
x.go:20: cannot use tv.Usec (type int32) as type C.__darwin_suseconds_t in assignment

Fixes #4255.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7231075
2013-02-01 08:34:21 -08:00
Russ Cox
f20e3a1065 cmd/cgo: fix line number annotations in generated C code
The old version was using go/ast's CommentGroup.Text method,
but that method drops leading blank lines from the result, so that
if the comment looked like one of

//
// syntax error
import "C"

/*
syntax error
*/
import "C"

then the line numbers for the syntax error would be off by the
number of leading blank lines (1 in each of the above cases).

The new text extractor preserves blank lines.

Fixes #4019.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7232071
2013-02-01 08:34:08 -08:00
Russ Cox
ed9fc7531d cmd/cgo: document //export preamble restriction
Fixes #3497.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7235075
2013-02-01 08:33:52 -08:00
Russ Cox
25d1fc9389 cmd/dist: fix build
The Unix and Plan 9 readfile call breset(b) but Windows was not,
leaving dregs in the buffer.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7229069
2013-01-31 22:57:30 -08:00
Russ Cox
7fc64a2a1d cmd/dist: redirect acid output to file to separate from errors
If runtime's proc.c does not compile, cmd/dist used to show
the compile errors in a sea of acid output, making them impossible
to find. Change the command invocation to write the acid output
to a file, so that the errors are the only thing shown on failure.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7221082
2013-01-31 22:02:20 -08:00
Russ Cox
ca727f1116 cmd/8l: fix build
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7241061
2013-01-31 16:13:48 -08:00
Ian Lance Taylor
193ff39ac9 test: add test that caused a gccgo compilation failure
Updates #4734.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7228079
2013-01-31 15:59:30 -08:00
Volker Dobler
7d8cc587b2 exp/cookiejar: remove external storage
This CL removes the external storage of a cookie jar
and minimized the exported API as discussed in [1].

[1] https://groups.google.com/d/topic/golang-dev/ygDB3nbir00/discussion

Update #1960.

R=nigeltao
CC=golang-dev
https://golang.org/cl/7235065
2013-02-01 10:56:08 +11:00
Russ Cox
31fafa5081 encoding/base64: fix test for ReadFull change
R=golang-dev
CC=golang-dev
https://golang.org/cl/7249045
2013-01-31 14:42:56 -08:00
Russ Cox
c0e805efd2 cmd/vet: add missing -all logic
R=golang-dev, cookieo9, bradfitz
CC=golang-dev
https://golang.org/cl/7260043
2013-01-31 14:37:47 -08:00
Russ Cox
0cb0f6d090 cmd/ld: support for linking with host linker
A step toward a fix for issue 4069.

To allow linking with arbitrary host object files, add a linker mode
that can generate a host object file instead of an executable.
Then the host linker can be invoked to generate the final executable.

This CL adds a new -hostobj flag that instructs the linker to write
a host object file instead of an executable.

That is, this works:

        go tool 6g x.go
        go tool 6l -hostobj -o x.o x.6
        ld -e _rt0_amd64_linux x.o
        ./a.out

as does:

        go tool 8g x.go
        go tool 8l -hostld ignored -o x.o x.8
        ld -m elf_i386 -e _rt0_386_linux x.o
        ./a.out

Because 5l was never updated to use the standard relocation scheme,
it will take more work to get this working on ARM.

This is a checkpoint of the basic functionality. It does not work
with cgo yet, and cgo is the main reason for the change.
The command-line interface will likely change too.
The gc linker has other information that needs to be returned to
the caller for use when invoking the host linker besides the single
object file.

R=iant, iant
CC=golang-dev
https://golang.org/cl/7060044
2013-01-31 14:11:32 -08:00
Russ Cox
739aa6b1ba cmd/vet: check for misplaced and malformed build tags
Fixes #4184.

R=golang-dev, bradfitz, minux.ma, cookieo9
CC=golang-dev
https://golang.org/cl/7251044
2013-01-31 13:52:27 -08:00
Russ Cox
662ff54212 io: guarantee err == nil for full reads in ReadFull and ReadAtLeast
This is a backwards compatible API change that fixes broken code.

In Go 1.0, ReadFull(r, buf) could return either len(buf), nil or len(buf), non-nil.
Most code expects only the former, so do that and document the guarantee.

Code that was correct before is still correct.
Code that was incorrect before, by assuming the guarantee, is now correct too.

The same applies to ReadAtLeast.

Fixes #4544.

R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/7235074
2013-01-31 13:46:12 -08:00
Russ Cox
4085426f7d net/url: normalize scheme to lower case (http not HTTP)
Also document %2f vs / ambiguity in URL.Path.

Fixes #3913.
Fixes #3659.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7225076
2013-01-31 13:45:43 -08:00
Russ Cox
d314e3a68e doc/codewalk: gofmt pig.go
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7221079
2013-01-31 13:42:26 -08:00
Adam Langley
5c659d7362 crypto/x509: test for negative RSA parameters.
Someone found software that generates negative numbers for the RSA
modulus in an X.509 certificate. Our error messages were very poor in
this case so this change improves that.

Update #4728
Return more helpful errors when RSA parameters are negative or zero.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7228072
2013-01-31 12:54:37 -05:00
Russ Cox
8b6534b78a cmd/go: many bug fixes
* Reject import paths of the form cmd/x/y.
* Reject 'go install' of command outside GOPATH
* Clearer error rejecting 'go install' of package outside GOPATH.
* Name temporary binary for first file in 'go run' list or for test.
* Provide a way to pass -ldflags arguments with spaces.
* Pass all Go files (even +build ignored ones) to go fix, go fmt, go vet.
* Reject 'go run foo_test.go'.
* Silence 'exit 1' prints from 'go tool' invocations.
* Make go test -xxxprofile leave binary behind for analysis.
* Reject ~ in GOPATH except on Windows.
* Get a little less confused by symlinks.
* Document that go test x y z runs three test binaries.
* Fix go test -timeout=0.
* Add -tags flag to 'go list'.
* Use pkg/gccgo_$GOOS_$GOARCH for gccgo output.

Fixes #3389.
Fixes #3500.
Fixes #3503.
Fixes #3760.
Fixes #3941.
Fixes #4007.
Fixes #4032.
Fixes #4074.
Fixes #4127.
Fixes #4140.
Fixes #4311.
Fixes #4568.
Fixes #4576.
Fixes #4702.

R=adg
CC=golang-dev
https://golang.org/cl/7225074
2013-01-31 08:06:38 -08:00
Russ Cox
87c3c1b002 cmd/vet: handle added string constants in printf format check
Fixes #4599.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7226067
2013-01-31 07:53:38 -08:00
Russ Cox
30985c1203 os: use signal strings where possible in ProcessState.String
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7228067
2013-01-31 07:53:18 -08:00
Russ Cox
592b480746 cmd/ld: retry short writes, to get error detail
Fixes #3802.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7228066
2013-01-31 07:49:33 -08:00
Russ Cox
956cd0059c encoding/json: document case-insensitive Unmarshal key matching
Fixes #4664.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7237060
2013-01-31 07:49:23 -08:00
Rémy Oudompheng
354a3a1513 cmd/8l: fix misassembling of MOVB involving (AX)(BX*1)
The linker accepts MOVB involving non-byte-addressable
registers, by generating XCHG instructions to AX or BX.
It does not handle the case where nor AX nor BX are available.

See also revision 1470920a2804.

Assembling
    TEXT ·Truc(SB),7,$0
    MOVB BP, (BX)(AX*1)
    RET

gives before:
   08048c60 <main.Truc>:
    8048c60:       87 dd         xchg   %ebx,%ebp
    8048c62:       88 1c 03      mov    %bl,(%ebx,%eax,1)
    8048c65:       87 dd         xchg   %ebx,%ebp
    8048c67:       c3            ret

and after:
   08048c60 <main.Truc>:
    8048c60:       87 cd         xchg   %ecx,%ebp
    8048c62:       88 0c 03      mov    %cl,(%ebx,%eax,1)
    8048c65:       87 cd         xchg   %ecx,%ebp
    8048c67:       c3            ret

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7226066
2013-01-31 08:52:46 +01:00
Rémy Oudompheng
73b83a228e cmd/gc: inlining of variadic functions.
R=rsc, lvd, golang-dev, kardianos
CC=golang-dev
https://golang.org/cl/7093050
2013-01-31 08:40:59 +01:00
Caleb Spare
0e74f04acc container/heap: split example into two
This adds a simple IntHeap example, and modifies the more complex
PriorityQueue example to make use of the index field it maintains.

Fixes #4331.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/7068048
2013-01-30 23:14:29 -08:00
Alex Brainman
bd75468a08 os: provide access to file LastAccessTime and CreationTime on windows
Fixes #4569.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6972047
2013-01-31 17:17:37 +11:00
Nigel Tao
6799b773eb exp/cookiejar: update PublicSuffixList doc comment to match the
examples at http://publicsuffix.org/.

That website previously listed pvt.k12.wy.us, but that was an error,
as confirmed by correspondance with submissions@publicsuffix.org, and
the website was fixed on 2013-01-23.

R=adg
CC=dr.volker.dobler, golang-dev
https://golang.org/cl/7241053
2013-01-31 14:12:43 +11:00
Robert Daniel Kortschak
92bc896909 fmt: improve go syntax handling of byte-derived arrays and slices
Fixes #4685.

R=golang-dev, adg, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/7205047
2013-01-30 17:53:53 -08:00
Rick Arnold
eea0f19990 encoding/json: improve performance of Unmarshal on primitive types
Attempt 2. The first fix was much faster but ignored syntax errors.

benchmark                      old ns/op    new ns/op    delta
BenchmarkCodeEncoder            74993543     72982390   -2.68%
BenchmarkCodeMarshal            77811181     75610637   -2.83%
BenchmarkCodeDecoder           213337123    190144982  -10.87%
BenchmarkCodeUnmarshal         212180972    190394852  -10.27%
BenchmarkCodeUnmarshalReuse    202113428    182106660   -9.90%
BenchmarkUnmarshalString            1343          919  -31.57%
BenchmarkUnmarshalFloat64           1149          908  -20.97%
BenchmarkUnmarshalInt64              967          778  -19.54%
BenchmarkSkipValue              28851581     28414125   -1.52%

benchmark                       old MB/s     new MB/s  speedup
BenchmarkCodeEncoder               25.88        26.59    1.03x
BenchmarkCodeMarshal               24.94        25.66    1.03x
BenchmarkCodeDecoder                9.10        10.21    1.12x
BenchmarkCodeUnmarshal              9.15        10.19    1.11x
BenchmarkSkipValue                 69.05        70.11    1.02x

Fixes #3949.

R=rsc
CC=golang-dev
https://golang.org/cl/7231058
2013-01-30 17:53:48 -08:00
Russ Cox
5215bedf49 A+C: Robert Daniel Kortschak (individual CLA)
Generated by addca.

R=gobot
CC=golang-dev
https://golang.org/cl/7245045
2013-01-30 17:53:07 -08:00