1
0
mirror of https://github.com/golang/go synced 2024-11-18 10:24:42 -07:00
Commit Graph

39736 Commits

Author SHA1 Message Date
Jeremy Jay
b325799cad compress/gzip: clarify that Multistream gzip requires a ByteReader
Change-Id: Ib24778f3172c011e6a39ee65dce8764f3cc911ea
GitHub-Last-Rev: 9c617c1e60
GitHub-Pull-Request: golang/go#30284
Reviewed-on: https://go-review.googlesource.com/c/162999
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 23:02:40 +00:00
Leon Klingele
d090429ea9 all: fix typos as reported by 'misspell'
Change-Id: I904b8655f21743189814bccf24073b6fbb9fc56d
GitHub-Last-Rev: b032c14394
GitHub-Pull-Request: golang/go#29997
Reviewed-on: https://go-review.googlesource.com/c/160421
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 23:02:05 +00:00
Derek Phan
337662f7ca io: align style of test comments in multi_test.go
Change-Id: Ic93a084311de46461ed3b30f4ac2fe11311e74d7
GitHub-Last-Rev: 32fbd63b10
GitHub-Pull-Request: golang/go#29705
Reviewed-on: https://go-review.googlesource.com/c/157642
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2019-02-26 23:01:20 +00:00
Alessandro Arzilli
08831b150c cmd/compile: avoid collisions between statictmps and user vars
Avoid name collisions between autogenerated statictmp variables and
user defined global variables.

Fixes #25113

Change-Id: I023eb42a5c2bd2f5352b046d33363faed87084dc
Reviewed-on: https://go-review.googlesource.com/c/142497
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 22:59:15 +00:00
Austin Clements
2cdebb5174 cmd/link: delete stale deadcode reference
Back when the linker did code generation after dead code elimination,
it had to know that references to runtime.read_tls_fallback could be
generated at code generation time (and never appear before that). Now
that code generation is done by the compiler, the references to
runtime.read_tls_fallback are obvious in the relocations, so the
linker no longer needs special knowledge of this symbol.

Change-Id: I9813a8478e85a6a13470b2d0528db53fd33fcfdf
Reviewed-on: https://go-review.googlesource.com/c/154601
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 22:58:39 +00:00
Marcel van Lohuizen
ef954a03eb bytes: hoist error creation out of function
generating frame information in errors will cause this
function to no longer be inlined.

Updates #29934.

Change-Id: I1d7bc11707f1872d7315f627bfb9a12afa41e358
Reviewed-on: https://go-review.googlesource.com/c/161760
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 22:57:25 +00:00
Tobias Klauser
c55eeeb718 runtime: use hw.ncpuonline sysctl in getncpu on openbsd
The number of CPUs reported by the hw.ncpu sysctl is twice as high as
the actual number of CPUs running on OpenBSD 6.4. with hyperthreading
disabled (hw.smt=0). Try hw.cpuonline first and fall back to hw.ncpu
in case it fails (which is the case on older OpenBSD before 6.4).

Fixes #30127

Change-Id: Id091234b8038cc9f7c40519d039fc1a05437c40d
Reviewed-on: https://go-review.googlesource.com/c/161757
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-02-26 22:56:59 +00:00
Ggicci
ea65d015b8 net/http: clean the path of the stripped URL by StripPrefix
The path of the new stripped URL should also be cleaned. Since an empty path
may cause unexpected errors in some HTTP handlers, e.g. http.ServeFile.

Fixes #30165

Change-Id: Ib44fdce6388b5d62ffbcab5266925ef8f13f26e2
Reviewed-on: https://go-review.googlesource.com/c/161738
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 22:55:59 +00:00
Yasser Abdolmaleki
5a7e8f466e crypto/tls: fix typo
Change-Id: If9332bae87449c94fc14710133614fcd84d2815c
Reviewed-on: https://go-review.googlesource.com/c/161726
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2019-02-26 22:54:37 +00:00
Tobias Klauser
38a4b37905 syscall: add empty line before marker comments in zsyscall_darwin_*.go
This was spotted during the review of the corresponding CL 154179 for
x/sys/unix. Let's change it in syscall as well to be consistent.

Change-Id: I33f25db1f6ba941b694c2aa276336448cc2b9b51
Reviewed-on: https://go-review.googlesource.com/c/154719
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 22:54:09 +00:00
Tooru Takahashi
8d057f3a0a cmd/internal/src: fix typo in pos.go
Change-Id: I31ac8845e72c3027c9a463b1f691f4d2b7913ec0
GitHub-Last-Rev: a6b185cc41
GitHub-Pull-Request: golang/go#29682
Reviewed-on: https://go-review.googlesource.com/c/157518
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
2019-02-26 22:53:21 +00:00
Keith Randall
f495f549ac cmd/compile: don't bother compiling functions named "_"
They can't be used, so we don't need code generated for them. We just
need to report errors in their bodies.

The compiler currently has a bunch of special cases sprinkled about
for "_" functions, because we never generate a linker symbol for them.
Instead, abort compilation earlier so we never reach any of that
special-case code.

Fixes #29870

Change-Id: I3530c9c353deabcf75ce9072c0b740e992349ee5
Reviewed-on: https://go-review.googlesource.com/c/158845
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-02-26 20:56:24 +00:00
Keith Randall
933e34ac99 cmd/compile: treat slice pointers as non-nil
var a []int = ...
p := &a[0]
_ = *p

We don't need to nil check on the 3rd line. If the bounds check on the 2nd
line passes, we know p is non-nil.

We rely on the fact that any cap>0 slice has a non-nil pointer as its
pointer to the backing array. This is true for all safely-constructed slices,
and I don't see any reason why someone would violate this rule using unsafe.

R=go1.13

Fixes #30366

Change-Id: I3ed764fcb72cfe1fbf963d8c1a82e24e3b6dead7
Reviewed-on: https://go-review.googlesource.com/c/163740
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-02-26 20:44:52 +00:00
Keith Randall
57976fe2b4 cmd/compile: update comment about x86 nop instruction generator
The comment about losing the high bits is incorrect.  We now use these
nops in places where they really need to be a nop.  (Before inline
marks, we used them just before deferreturn calls, so they could
clobber any caller-saved values.)

Change-Id: I433d1ec455aa37dab8fef6eb7d407f3737dbb97f
Reviewed-on: https://go-review.googlesource.com/c/158057
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
2019-02-26 20:41:14 +00:00
Alex Brainman
5cf4e442a5 runtime: fix syscall.NewCallback to return all bits for uintptr values
syscall.NewCallback mistakenly used MOVL even for windows/amd64,
which only returned the lower 32 bits regardless of the architecture.
This was due to a copy and paste after porting from windows/386.
The code now uses MOVQ, which will return all the available bits.

Also adjust TestReturnAfterStackGrowInCallback to ensure we never
regress.

Fixes #29331

Change-Id: I4f5c8021c33f234c2bb7baa9ef7a6b4870172509
Reviewed-on: https://go-review.googlesource.com/c/159579
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2019-02-26 20:22:39 +00:00
Josh Bleecher Snyder
c97e576576 html/template: use strings.Builder
...and size initial buffers more accurately.

Easy pickings only. More might remain.

name                             old time/op    new time/op    delta
CSSEscaper-8                       1.17µs ± 1%    0.80µs ± 2%  -31.55%  (p=0.000 n=44+48)
CSSEscaperNoSpecials-8              205ns ± 2%     204ns ± 3%   -0.73%  (p=0.014 n=46+49)
DecodeCSS-8                         438ns ± 2%     436ns ± 2%     ~     (p=0.099 n=48+47)
DecodeCSSNoSpecials-8              6.11ns ± 3%    5.93ns ± 3%   -2.85%  (p=0.000 n=50+48)
CSSValueFilter-8                    149ns ± 0%     145ns ± 0%   -2.68%  (p=0.000 n=32+35)
CSSValueFilterOk-8                  238ns ± 2%     234ns ± 2%   -1.40%  (p=0.000 n=49+47)
EscapedExecute-8                   2.53µs ± 2%    2.55µs ± 1%   +0.87%  (p=0.000 n=48+49)
HTMLNospaceEscaper-8               1.35µs ± 2%    0.92µs ± 1%  -31.74%  (p=0.000 n=48+48)
HTMLNospaceEscaperNoSpecials-8      278ns ± 2%     263ns ± 2%   -5.17%  (p=0.000 n=47+49)
StripTags-8                         778ns ± 2%     786ns ± 1%   +0.96%  (p=0.000 n=46+47)
StripTagsNoSpecials-8              84.2ns ± 1%    84.1ns ± 1%     ~     (p=0.300 n=48+48)
JSValEscaperWithNum-8               506ns ± 2%     486ns ± 3%   -3.82%  (p=0.000 n=47+45)
JSValEscaperWithStr-8              1.61µs ± 1%    1.64µs ± 1%   +1.75%  (p=0.000 n=44+49)
JSValEscaperWithStrNoSpecials-8     548ns ± 2%     552ns ± 2%   +0.78%  (p=0.000 n=48+46)
JSValEscaperWithObj-8              1.91µs ± 2%    1.87µs ± 1%   -2.08%  (p=0.000 n=49+47)
JSValEscaperWithObjNoSpecials-8     735ns ± 2%     742ns ± 2%   +1.01%  (p=0.000 n=47+49)
JSStrEscaperNoSpecials-8            228ns ± 4%     211ns ± 3%   -7.53%  (p=0.000 n=50+49)
JSStrEscaper-8                     1.11µs ± 1%    0.78µs ± 1%  -29.94%  (p=0.000 n=48+48)
JSRegexpEscaperNoSpecials-8         214ns ± 2%     212ns ± 3%   -1.12%  (p=0.000 n=50+49)
JSRegexpEscaper-8                  1.17µs ± 0%    0.79µs ± 1%  -31.92%  (p=0.000 n=48+47)
TemplateSpecialTags-8               172µs ± 1%     172µs ± 1%     ~     (p=0.976 n=48+47)
URLEscaper-8                       1.88µs ± 2%    1.87µs ± 2%   -0.56%  (p=0.001 n=49+49)
URLEscaperNoSpecials-8              162ns ± 1%     169ns ± 1%   +3.76%  (p=0.000 n=49+50)
URLNormalizer-8                    1.29µs ± 3%    1.29µs ± 2%   -0.37%  (p=0.041 n=48+48)
URLNormalizerNoSpecials-8           185ns ± 1%     186ns ± 1%   +0.15%  (p=0.013 n=49+49)
SrcsetFilter-8                      616ns ± 1%     618ns ± 1%   +0.36%  (p=0.000 n=46+46)
SrcsetFilterNoSpecials-8            359ns ± 0%     352ns ± 0%   -1.93%  (p=0.000 n=40+43)
[Geo mean]                          560ns          525ns        -6.17%

name                             old alloc/op   new alloc/op   delta
CSSEscaper-8                         672B ± 0%      336B ± 0%  -50.00%  (p=0.000 n=50+50)
CSSEscaperNoSpecials-8              0.00B          0.00B          ~     (all equal)
DecodeCSS-8                          160B ± 0%      160B ± 0%     ~     (all equal)
DecodeCSSNoSpecials-8               0.00B          0.00B          ~     (all equal)
CSSValueFilter-8                    96.0B ± 0%     96.0B ± 0%     ~     (all equal)
CSSValueFilterOk-8                  48.0B ± 0%     48.0B ± 0%     ~     (all equal)
EscapedExecute-8                     688B ± 0%      624B ± 0%   -9.30%  (p=0.000 n=50+50)
HTMLNospaceEscaper-8                 752B ± 0%      368B ± 0%  -51.06%  (p=0.000 n=50+50)
HTMLNospaceEscaperNoSpecials-8      48.0B ± 0%     32.0B ± 0%  -33.33%  (p=0.000 n=50+50)
StripTags-8                          224B ± 0%      224B ± 0%     ~     (all equal)
StripTagsNoSpecials-8                112B ± 0%      112B ± 0%     ~     (all equal)
JSValEscaperWithNum-8               96.0B ± 0%     40.0B ± 0%  -58.33%  (p=0.000 n=50+50)
JSValEscaperWithStr-8                384B ± 0%      384B ± 0%     ~     (all equal)
JSValEscaperWithStrNoSpecials-8     96.0B ± 0%     96.0B ± 0%     ~     (all equal)
JSValEscaperWithObj-8                448B ± 0%      448B ± 0%     ~     (all equal)
JSValEscaperWithObjNoSpecials-8      160B ± 0%      160B ± 0%     ~     (all equal)
JSStrEscaperNoSpecials-8            0.00B          0.00B          ~     (all equal)
JSStrEscaper-8                       672B ± 0%      336B ± 0%  -50.00%  (p=0.000 n=50+50)
JSRegexpEscaperNoSpecials-8         0.00B          0.00B          ~     (all equal)
JSRegexpEscaper-8                    672B ± 0%      336B ± 0%  -50.00%  (p=0.000 n=50+50)
TemplateSpecialTags-8              48.0kB ± 0%    47.9kB ± 0%   -0.13%  (p=0.000 n=50+48)
URLEscaper-8                         336B ± 0%      336B ± 0%     ~     (all equal)
URLEscaperNoSpecials-8               112B ± 0%      112B ± 0%     ~     (all equal)
URLNormalizer-8                      176B ± 0%      176B ± 0%     ~     (all equal)
URLNormalizerNoSpecials-8            112B ± 0%      112B ± 0%     ~     (all equal)
SrcsetFilter-8                       160B ± 0%      160B ± 0%     ~     (all equal)
SrcsetFilterNoSpecials-8             160B ± 0%      160B ± 0%     ~     (all equal)
[Geo mean]                           259B           216B       -16.60%

name                             old allocs/op  new allocs/op  delta
CSSEscaper-8                         4.00 ± 0%      2.00 ± 0%  -50.00%  (p=0.000 n=50+50)
CSSEscaperNoSpecials-8               0.00           0.00          ~     (all equal)
DecodeCSS-8                          1.00 ± 0%      1.00 ± 0%     ~     (all equal)
DecodeCSSNoSpecials-8                0.00           0.00          ~     (all equal)
CSSValueFilter-8                     2.00 ± 0%      2.00 ± 0%     ~     (all equal)
CSSValueFilterOk-8                   3.00 ± 0%      3.00 ± 0%     ~     (all equal)
EscapedExecute-8                     18.0 ± 0%      18.0 ± 0%     ~     (all equal)
HTMLNospaceEscaper-8                 5.00 ± 0%      3.00 ± 0%  -40.00%  (p=0.000 n=50+50)
HTMLNospaceEscaperNoSpecials-8       1.00 ± 0%      1.00 ± 0%     ~     (all equal)
StripTags-8                          3.00 ± 0%      3.00 ± 0%     ~     (all equal)
StripTagsNoSpecials-8                2.00 ± 0%      2.00 ± 0%     ~     (all equal)
JSValEscaperWithNum-8                3.00 ± 0%      3.00 ± 0%     ~     (all equal)
JSValEscaperWithStr-8                2.00 ± 0%      2.00 ± 0%     ~     (all equal)
JSValEscaperWithStrNoSpecials-8      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
JSValEscaperWithObj-8                3.00 ± 0%      3.00 ± 0%     ~     (all equal)
JSValEscaperWithObjNoSpecials-8      3.00 ± 0%      3.00 ± 0%     ~     (all equal)
JSStrEscaperNoSpecials-8             0.00           0.00          ~     (all equal)
JSStrEscaper-8                       4.00 ± 0%      2.00 ± 0%  -50.00%  (p=0.000 n=50+50)
JSRegexpEscaperNoSpecials-8          0.00           0.00          ~     (all equal)
JSRegexpEscaper-8                    4.00 ± 0%      2.00 ± 0%  -50.00%  (p=0.000 n=50+50)
TemplateSpecialTags-8                 185 ± 0%       185 ± 0%     ~     (all equal)
URLEscaper-8                         4.00 ± 0%      4.00 ± 0%     ~     (all equal)
URLEscaperNoSpecials-8               2.00 ± 0%      2.00 ± 0%     ~     (all equal)
URLNormalizer-8                      3.00 ± 0%      3.00 ± 0%     ~     (all equal)
URLNormalizerNoSpecials-8            2.00 ± 0%      2.00 ± 0%     ~     (all equal)
SrcsetFilter-8                       3.00 ± 0%      3.00 ± 0%     ~     (all equal)
SrcsetFilterNoSpecials-8             3.00 ± 0%      3.00 ± 0%     ~     (all equal)
[Geo mean]                           3.41           3.05       -10.65%

Change-Id: I809ea56495ce1881656af7e24621448ab64b449a
Reviewed-on: https://go-review.googlesource.com/c/155919
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 20:12:09 +00:00
Josh Bleecher Snyder
c63dc6d459 cmd/compile: remove badgerbadgerbadger optimization
As discussed in #29242, this optimization is for a bash-ism.
No one writes Go code like this.

In this repo, it triggers only in test/fixedbugs/bug425.go
and that appears to be accidental.

Fixes #29242

Change-Id: I257e6ecc73f24680f7282c6ab28729de4e8b27af
Reviewed-on: https://go-review.googlesource.com/c/163728
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 20:11:48 +00:00
Russ Cox
d6311ff1e4 math/big: add %#b and %O integer formats
Matching fmt, %#b now prints an 0b prefix,
and %O prints octal with an 0o prefix.

See golang.org/design/19308-number-literals for background.

For #19308.
For #12711.

Change-Id: I139c5a9a1dfae15415621601edfa13c6a5f19cfc
Reviewed-on: https://go-review.googlesource.com/c/160250
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-02-26 19:39:19 +00:00
Russ Cox
675503c507 math/big: add %x float format
big.Float already had %p for printing hex format,
but that format normalizes differently from fmt's %x
and ignores precision entirely.

This CL adds %x to big.Float, matching fmt's behavior:
the verb is spelled 'x' not 'p', the mantissa is normalized
to [1, 2), and precision is respected.

See golang.org/design/19308-number-literals for background.

For #29008.

Change-Id: I9c1b9612107094856797e5b0b584c556c1914895
Reviewed-on: https://go-review.googlesource.com/c/160249
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-02-26 19:39:11 +00:00
Josh Bleecher Snyder
1e58bb1491 cmd/compile: inline checknil
Now that checknil has only a single caller, inline it.

Passes toolstash-check.

Change-Id: I5b13596bef84dd9a3e7f4bff8560903f1e54acfb
Reviewed-on: https://go-review.googlesource.com/c/148829
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 19:28:58 +00:00
Daniel Martí
e90e7a59dc encoding/base32: simplify and speed up decoder
First, we can lift the enc.decodeMap nil check out of the loop.

Second, we can make it clear to the compiler that 'in := src[0]' doesn't
need a bounds check, by making len(src)==0 a single if check that always
stops the loop. This is by far the largest speed-up.

Third, we can use a dst slice index instead of reslicing dst, which
removes work from the loop body.

While at it, we can merge the two 'switch dlen' pieces of code, which
simplifies the code and doesn't affect performance.

name            old time/op    new time/op    delta
DecodeString-8    80.2µs ± 0%    67.5µs ± 0%  -15.81%  (p=0.002 n=6+6)

name            old speed      new speed      delta
DecodeString-8   163MB/s ± 0%   194MB/s ± 0%  +18.78%  (p=0.002 n=6+6)

Change-Id: Iefeaae94c03453f8760452b1da706a77b3522718
Reviewed-on: https://go-review.googlesource.com/c/154422
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 19:20:07 +00:00
Agniva De Sarker
da50e10c2e go/doc: skip escaping comments in pre-formatted blocks
CL 150377 made the change of converting smart quotes to their html escaped entities
for ToHTML, and to unicode quotes for ToText. But for ToText, the change
converted the quotes in pre-formatted text too.

This fixes that behavior to not touch any text in pre-formatted blocks, which also
makes the behavior consistent with ToHTML.

Fixes #29730

Change-Id: I58e0216cbdbe189d06d82147e5a02b620af14734
Reviewed-on: https://go-review.googlesource.com/c/162922
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-02-26 18:51:37 +00:00
Agniva De Sarker
39fa3f171c cmd/compile: fix a typo in assignment mismatch error
Fixes #30087

Change-Id: Ic6d80f8e6e1831886af8613420b1bd129a1b4850
Reviewed-on: https://go-review.googlesource.com/c/161577
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 18:50:48 +00:00
Marat Khabibullin
576a3c61d9 crypto/x509: remove redundant check for nil in tests
Comparing err variable to be not nil is redundant in this case.
The code above ensures that it is always not nil.

Updates #30208

Change-Id: I0a41601273de36a05d22270a743c0bdedeb1d0bf
GitHub-Last-Rev: 372e0fd48f
GitHub-Pull-Request: golang/go#30213
Reviewed-on: https://go-review.googlesource.com/c/162439
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 18:48:34 +00:00
Michael Fraenkel
6d781decad cmd/compile: confusing error if composite literal field is a method
When looking for the field specified in a composite literal, check that
the specified name is actually a field and not a method.

Fixes #29855.

Change-Id: Id77666e846f925907b1eec64213b1d25af8a2466
Reviewed-on: https://go-review.googlesource.com/c/158938
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-02-26 18:42:07 +00:00
Marat Khabibullin
c6e47069af net/textproto: prevent test from failing with nil pointer dereference
The variable err could have nil value when we call err.Error(),
because after we check it for nil above we continue the test
(t.Errorf doesn't stop the test execution).

Updates #30208

Change-Id: Ibcf38698326c69c06068989510311e37806995c6
GitHub-Last-Rev: 3ab20f6d7f
GitHub-Pull-Request: golang/go#30214
Reviewed-on: https://go-review.googlesource.com/c/162457
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 18:40:29 +00:00
Filippo Valsorda
8d72e59853 crypto/tls: remove superfluous for label
Change-Id: I8ea3043fcbaf7a5f73b2a796171a7f1cb3cb3693
Reviewed-on: https://go-review.googlesource.com/c/158818
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 18:38:04 +00:00
Josh Bleecher Snyder
01971b97c1 cmd/compile: cull dead code
The special case for ODOTPTR to handle zero-width fields is unneeded.
It is an artifact of the old backend, from which time this code dates.
The Node to SSA converter is careful to insert a nil check.
This is tested in test/nilptr2.go, among other places.

Passes toolstash-check.

Change-Id: I6c1d99f7ff5abdae9aa08ee047dc088a3fe8dc3c
Reviewed-on: https://go-review.googlesource.com/c/148828
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-02-26 18:37:19 +00:00
Elias Naur
8ca559eed5 cmd/dist: skip Fortran tests on Android
They don't work on Android but will be run if the host has gfortran
installed.

Change-Id: I983c5695a9e963def90e4f8264fb00077a0c5e53
Reviewed-on: https://go-review.googlesource.com/c/163838
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 18:21:15 +00:00
Ketan Parmar
8cf1d1634a encoding/json: add example for json.HTMLEscape
Change-Id: Ib00fcfd46eae27eea0a3d4cab4406f4c461fb57b
Reviewed-on: https://go-review.googlesource.com/c/160517
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 18:14:45 +00:00
Daniel Martí
15b4c71a91 text/template: error on method calls on nil interfaces
Trying to call a method on a nil interface is a panic in Go. For
example:

	var stringer fmt.Stringer
	println(stringer.String()) // nil pointer dereference

In https://golang.org/cl/143097 we started recovering panics encountered
during function and method calls. However, we didn't handle this case,
as text/template panics before evalCall is ever run.

In particular, reflect's MethodByName will panic if the receiver is of
interface kind and nil:

	panic: reflect: Method on nil interface value

Simply add a check for that edge case, and have Template.Execute return
a helpful error. Note that Execute shouldn't just error if the interface
contains a typed nil, since we're able to find a method to call in that
case.

Finally, add regression tests for both the nil and typed nil interface
cases.

Fixes #30143.

Change-Id: Iffb21b40e14ba5fea0fcdd179cd80d1f23cabbab
Reviewed-on: https://go-review.googlesource.com/c/161761
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-02-26 18:05:09 +00:00
Daniel Martí
acf786f4fb cmd/compile: remove unused func eqtypenoname
Its only use was removed in golang.org/cl/114797, committed in October
2018.

Change-Id: I6560ccfb10d7c763f6470b20c853716779c18cee
Reviewed-on: https://go-review.googlesource.com/c/158897
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-02-26 18:04:04 +00:00
Elias Naur
7be432e659 misc/android: copy testdata directories to device before running
We've got away with not copying the testdata directories for the
standard library because the exec wrapper also pushes almost the
entire $GOROOT tree to the device, including testdata directories.

Similar to what the iOS exec wrapper does.

Change-Id: I91ef63ef84a658fc8843002890132c64b7c1d20e
Reviewed-on: https://go-review.googlesource.com/c/163626
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 18:01:15 +00:00
Elias Naur
1aa0fcff46 misc/android: serialize adb commands on android emulators
Android emulator builders are soon to join the trybot set. To avoid
flaky runs, work around a longstanding adb bug where concurrent adb
commands sometimes fail.

I haven't seen the problem on actual devices until recently. It seems
that the recently added "adb wait-for-device" can introduce flakyness
with errors such as:

adb: error: failed to get feature set: protocol fault (couldn't read status): Connection reset by peer

Instead of working around that, give up and serialize use of adb
everywhere.

Fixes #23795
Updates #23824

Change-Id: If347c9981fa32ff8a1e14b7454f122ef682450a6
Reviewed-on: https://go-review.googlesource.com/c/163625
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 18:01:06 +00:00
Elias Naur
e3d99a3f86 misc/android,cmd/dist: move $GOROOT copying to the exec wrapper
To run the standard library tests on Android, the androidtest.bash
script copies GOROOT to the device. Move that logic to the android
exec wrapper, thereby making androidtest.bash obsolete.

Apart from making Android less special, the sharded builder
infrastructure should now be able to run (emulated) Android builders
and trybots without special treatment.

Updates #23824

Change-Id: I41591fea9a15b38c6dcf84046ea57f1e9165eaa5
Reviewed-on: https://go-review.googlesource.com/c/163619
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 18:00:48 +00:00
Elias Naur
3ef7e3d44f cmd/vendor/golang.org/x/sys: re-vendor
Fixes #29423

Change-Id: I376d0776c3810c2273d1ea234ebe681d5fd2ae64
Reviewed-on: https://go-review.googlesource.com/c/163623
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-02-26 18:00:13 +00:00
Elias Naur
da2d02a935 cmd/dist: build exec wrappers during bootstrap
The androidtest.bash script encodes the additional steps to build
Go and run tests on Android. In order to add sharded builders and
trybots, Android needs to fit into the usual make.bash + cmd/dist test
pattern.

This change moves building the exec wrapper into cmd/dist bootstrap.

Do the same for iOS while we're here.

Updates #23824

Change-Id: I58a1b0679c3a6c92fdc7fff464b469641f1fee74
Reviewed-on: https://go-review.googlesource.com/c/163618
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 17:59:23 +00:00
Michael Munday
42a82ce1a7 math/bits: optimize Reverse32 and Reverse64
Use ReverseBytes32 and ReverseBytes64 to speed up these functions.
The byte reversal functions are intrinsics on most platforms and
generally compile to a single instruction.

name       old time/op  new time/op  delta
Reverse32  2.41ns ± 1%  1.94ns ± 3%  -19.60%  (p=0.000 n=20+19)
Reverse64  3.85ns ± 1%  2.56ns ± 1%  -33.32%  (p=0.000 n=17+19)

Change-Id: I160bf59a0c7bd5db94114803ec5a59fae448f096
Reviewed-on: https://go-review.googlesource.com/c/159358
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-02-26 17:52:08 +00:00
Iskander Sharipov
b65ab889ab net/rpc: fix args order in strings.Contains call
The old code looks suspicious and is fragile.
It would fail if error messages were not totally the same.
Swapped the arguments order to fix that.

Change-Id: Id5df7242fb9224d0090245286ef8986ebb15e921
Reviewed-on: https://go-review.googlesource.com/c/161157
Run-TryBot: Iskander Sharipov <quasilyte@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-02-26 17:51:35 +00:00
Daniel Martí
856525ce5c text/template: improve nil errors in evalField
If we're accessing a field on a nil struct pointer, and that field is
present in the type, we should print a "nil pointer evaluating X.Y" error
instead of the broader "can't evaluate field Y in X". The latter error
should still be used for the cases where the field is simply missing.

While at it, remove the isNil checks in the struct and map cases. The
indirect func will only return a true isNil when returning a pointer or
interface reflect.Value, so it's impossible for either of these checks
to be useful.

Finally, extend the test suite to test a handful of these edge cases,
including the one shown in the original issue.

Fixes #29137.

Change-Id: I53408ced8a7b53807a0a8461b6baef1cd01d25ae
Reviewed-on: https://go-review.googlesource.com/c/153341
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-02-26 17:50:11 +00:00
Daniel Martí
be9c534cde cmd/compile: don't crash on -d=ssa/
I forgot how to pull up the ssa debug options help, so instead of
writing -d=ssa/help, I just wrote -d=ssa/. Much to my amusement, the
compiler just crashed, as shown below. Fix that.

	panic: runtime error: index out of range

	goroutine 1 [running]:
	cmd/compile/internal/ssa.PhaseOption(0x7ffc375d2b70, 0x0, 0xdbff91, 0x5, 0x1, 0x0, 0x0, 0x1, 0x1)
	    /home/mvdan/tip/src/cmd/compile/internal/ssa/compile.go:327 +0x1876
	cmd/compile/internal/gc.Main(0xde7bd8)
	    /home/mvdan/tip/src/cmd/compile/internal/gc/main.go:411 +0x41d0
	main.main()
	    /home/mvdan/tip/src/cmd/compile/main.go:51 +0xab

Change-Id: Ia2ad394382ddf8f4498b16b5cfb49be0317fc1aa
Reviewed-on: https://go-review.googlesource.com/c/154421
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-02-26 17:50:01 +00:00
Alberto Donizetti
467456b0af doc: add 1.12 to the project history
Go 1.12 is released, but it's currently not listed in the
https://golang.org/project page.

Change-Id: Ib5820f74245e4c986014c64eb40fa2911473e64b
Reviewed-on: https://go-review.googlesource.com/c/163837
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 17:31:55 +00:00
Alberto Donizetti
c0101b1961 time: parse 1us in Nanoseconds example
The example for Nanoseconds() currently reads:

  ns, _ := time.ParseDuration("1000ns")
  fmt.Printf("one microsecond has %d nanoseconds.", ns.Nanoseconds())

which is not terribly interesting: it seems obvious that parsing
"1000ns" and then calling Nanoseconds() will print 1000. The mention
of microseconds in the text suggests that the author's intention was,
instead, to write something like this:

  u, _ := time.ParseDuration("1us")

i.e. build a time value by parsing 1 microsecond, and then print the
value in nanoseconds. Change the example to do this.

Change-Id: I4ddb123f0935a12cda3b5d6f1ca919bfcd6383d6
Reviewed-on: https://go-review.googlesource.com/c/163622
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 17:22:58 +00:00
Bryan C. Mills
b5a68a9e41 misc/cgo: skip cgotest.TestCrossPackageTests on iOS and set PWD
I hope that this will fix the tests on iOS, but 'gomote create' isn't
giving me an instance I can test with. (Please patch and test before
approving.)

Updates #15919
Updates #30228

Change-Id: I1b7cd30d5b127a1ad3243b329fa005d229f69a24
Reviewed-on: https://go-review.googlesource.com/c/163726
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Elias Naur <mail@eliasnaur.com>
2019-02-26 13:29:07 +00:00
Russ Cox
3cf56e78d8 text/template: accept new number syntax
This CL updates text/template's scanner to accept the
new number syntaxes:

 - Hexadecimal floating-point values.
 - Digit-separating underscores.
 - Leading 0b and 0o prefixes.

See golang.org/design/19308-number-literals for background.

For #12711.
For #19308.
For #28493.
For #29008.

Change-Id: I68c16ea35c3f506701063781388de72bafee6b8d
Reviewed-on: https://go-review.googlesource.com/c/160248
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-02-26 05:18:38 +00:00
Russ Cox
f601d412ce fmt: scan new number syntax
This CL updates fmt's scanner to accept the new number syntaxes:

 - Hexadecimal floating-point values.
 - Digit-separating underscores.
 - Leading 0b and 0o prefixes.

See golang.org/design/19308-number-literals for background.

For #12711.
For #19308.
For #28493.
For #29008.

Change-Id: I5582af5c94059c781e6cf4e862441d3df3006adf
Reviewed-on: https://go-review.googlesource.com/c/160247
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-02-26 05:18:24 +00:00
Russ Cox
ac51237aff fmt: format 0b, 0o prefixes in %#b and %O
This CL modifies fmt's printer to implement %#b and %O
to emit leading 0b and 0o prefixes on binary and octal.
(%#o is already taken and emits "0377"; %O emits "0o377".)

See golang.org/design/19308-number-literals for background.

For #19308.
For #12711.
Vet update is #29986.

Change-Id: I7c38a4484c48a03abe9f6d45c7d981c7c314f583
Reviewed-on: https://go-review.googlesource.com/c/160246
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-02-26 05:16:56 +00:00
Russ Cox
e1a6d1fc08 fmt: format hex floats and complexes
This CL modifies fmt's printer to implement %x and %X
for formatting floating-point data (floats and complexes)
in standard hexadecimal notation.

See golang.org/design/19308-number-literals for background.

For #29008.
Vet update is #29986.

Change-Id: If2842a11631bc393a1ebcf6914ed07658652af5a
Reviewed-on: https://go-review.googlesource.com/c/160245
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-02-26 05:16:49 +00:00
Bryan C. Mills
50bb2b6b0f cmd/go: allow "stdout" and "stderr" as inputs to script_test "cp" command
Updates #30241

Change-Id: I543d8914faf810835d3327baa3c84b3dff124156
Reviewed-on: https://go-review.googlesource.com/c/163519
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-02-26 02:45:57 +00:00
Bryan C. Mills
1670da9ee4 test: add a go.mod file in the working directory of nosplit.go
Updates #30228

Change-Id: I41bbedf15fa51242f69a3b1ecafd0d3191271799
Reviewed-on: https://go-review.googlesource.com/c/163518
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-02-26 02:44:45 +00:00