aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Amedee <carlos@golang.org>2020-02-06 14:36:23 -0500
committerCarlos Amedee <carlos@golang.org>2020-02-06 20:10:47 +0000
commitd898c7b5449d949760211c35999083f934542b53 (patch)
tree0d6f2cd0ff87d98c9acf91d7f7fc3b88c3c07005
parent29ccdfc8535020ecb4b048f9158efe5f454ed918 (diff)
parentab7c174183b05e36dabe0aa1943a0a4302b940d0 (diff)
downloadgo-d898c7b5449d949760211c35999083f934542b53.tar.gz
go-d898c7b5449d949760211c35999083f934542b53.zip
[release-branch.go1.14] all: merge master into release-branch.go1.14
ab7c174183 testing: make Cleanup work for benchmarks too. ee3a3717aa doc/go1.14: disable text/template processing in HTML page dd0aa799eb doc/go1.14: quote {{ and }} in text/template note 9ee51745f7 doc/go1.14: mention better error checking in text/template e5b9c10689 doc/go1.14: document io/ioutil.TempDir's predictable prefix+suffix 7a36fa4002 crypto/x509: fix godoc for MarshalPKCS8PrivateKey 921ceadd29 runtime: rewrite a comment in malloc.go 88ae4ccefb math/big: reintroduce pre-Go 1.14 mention in GCD docs 60f11c44c0 doc/go1.14: document http.ServeFile large file fix for Windows 8a4d05cf07 cmd/go/internal/vet: only set work.VetExplicit if the list of explicit flags is non-empty 702226f933 doc/install.html: streamline the “Test your installation” step and make it module-agnostic ffd4e32885 doc/go1.14: add remarks about range inference and check removal Change-Id: Ie5f46d6f77fd792687f2aba0c1fa92cbe8a3a45b
-rw-r--r--doc/go1.14.html37
-rw-r--r--doc/install.html27
-rw-r--r--src/cmd/go/internal/vet/vet.go4
-rw-r--r--src/cmd/go/testdata/script/vet_flags.txt11
-rw-r--r--src/runtime/malloc.go7
-rw-r--r--src/testing/benchmark.go1
-rw-r--r--src/testing/sub_test.go40
7 files changed, 99 insertions, 28 deletions
diff --git a/doc/go1.14.html b/doc/go1.14.html
index 7cf73bc501..4e7381b900 100644
--- a/doc/go1.14.html
+++ b/doc/go1.14.html
@@ -1,7 +1,6 @@
<!--{
"Title": "Go 1.14 Release Notes",
- "Path": "/doc/go1.14",
- "Template": true
+ "Path": "/doc/go1.14"
}-->
<!--
@@ -401,6 +400,11 @@ appropriately.)
This API may change in future releases.
</p>
+<p><!-- CL 174704 --><!-- CL 196784 -->
+ Bounds check elimination now uses information from slice creation and can
+ eliminate checks for indexes with types smaller than <code>int</code>.
+</p>
+
<h2 id="library">Core library</h2>
<p>
@@ -564,6 +568,16 @@ appropriately.)
</dd>
</dl><!-- go/build -->
+<dl id="io/ioutil"><dt><a href="/pkg/io/ioutil/">io/ioutil</a></dt>
+ <dd>
+ <p><!-- CL 198488 -->
+ <a href="/pkg/io/ioutil/#TempDir"><code>TempDir</code></a> can now create directories
+ whose names have predictable prefixes and suffixes. As with TempFile, if the pattern
+ contains a '*', the random string replaces the last '*'.
+ </p>
+ </dd>
+</dl>
+
<dl id="log"><dt><a href="/pkg/log/">log</a></dt>
<dd>
<p><!-- CL 186182 -->
@@ -677,6 +691,11 @@ appropriately.)
use <code>DialTLSContext</code>, which allows the transport to
cancel dials as soon as they are no longer needed.
</p>
+
+ <p><!-- CL 192518, CL 194218 -->
+ On Windows, <a href="/pkg/net/http/#ServeFile"><code>ServeFile</code></a> now correctly
+ serves files larger than 2GB.
+ </p>
</dd>
</dl><!-- net/http -->
@@ -803,6 +822,20 @@ appropriately.)
</p>
</dl><!-- testing -->
+<dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt>
+ <dd>
+ <p><!-- CL 206124 -->
+ The text/template package now correctly reports errors when a
+ parenthesized argument is used as a function.
+ This most commonly shows up in erroneous cases like
+ <code>{{if (eq .F "a") or (eq .F "b")}}</code>.
+ This should be written as <code>{{if or (eq .F "a") (eq .F "b")}}</code>.
+ The erroneous case never worked as expected, and will now be
+ reported with an error <code>can't give argument to non-function</code>.
+ </p>
+ </dd>
+</dl><!-- text/template -->
+
<dl id="unicode"><dt><a href="/pkg/unicode/">unicode</a></dt>
<dd>
<p>
diff --git a/doc/install.html b/doc/install.html
index 05b6d0538c..40faadb2fa 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -192,20 +192,11 @@ Settings" option inside the "System" control panel.
<h2 id="testing">Test your installation</h2>
<p>
-Check that Go is installed correctly by setting up a workspace
-and building a simple program, as follows.
+Check that Go is installed correctly by building a simple program, as follows.
</p>
<p>
-Create your <a href="code.html#Workspaces">workspace</a> directory,
-<code class="testUnix">$HOME/go</code><code class="testWindows">%USERPROFILE%\go</code>.
-(If you'd like to use a different directory,
-you will need to <a href="https://golang.org/wiki/SettingGOPATH">set the <code>GOPATH</code> environment variable</a>.)
-</p>
-
-<p>
-Next, make the directory <code class="testUnix">src/hello</code><code class="testWindows">src\hello</code> inside your workspace,
-and in that directory create a file named <code>hello.go</code> that looks like:
+Create a file named <code>hello.go</code> that looks like:
</p>
<pre>
@@ -223,19 +214,17 @@ Then build it with the <code>go</code> tool:
</p>
<pre class="testUnix">
-$ <b>cd $HOME/go/src/hello</b>
-$ <b>go build</b>
+$ <b>go build hello.go</b>
</pre>
<pre class="testWindows">
-C:\&gt; <b>cd %USERPROFILE%\go\src\hello</b>
-C:\Users\Gopher\go\src\hello&gt; <b>go build</b>
+C:\Users\Gopher\go\src\hello&gt; <b>go build hello.go</b>
</pre>
<p>
The command above will build an executable named
<code class="testUnix">hello</code><code class="testWindows">hello.exe</code>
-in the directory alongside your source code.
+in the current directory alongside your source code.
Execute it to see the greeting:
</p>
@@ -254,12 +243,6 @@ If you see the "hello, world" message then your Go installation is working.
</p>
<p>
-You can run <code>go</code> <code>install</code> to install the binary into
-your workspace's <code>bin</code> directory
-or <code>go</code> <code>clean</code> <code>-i</code> to remove it.
-</p>
-
-<p>
Before rushing off to write Go code please read the
<a href="/doc/code.html">How to Write Go Code</a> document,
which describes some essential concepts about using the Go tools.
diff --git a/src/cmd/go/internal/vet/vet.go b/src/cmd/go/internal/vet/vet.go
index 660a739fbb..4e09c0fb9c 100644
--- a/src/cmd/go/internal/vet/vet.go
+++ b/src/cmd/go/internal/vet/vet.go
@@ -51,7 +51,9 @@ func runVet(cmd *base.Command, args []string) {
work.BuildInit()
work.VetFlags = vetFlags
- work.VetExplicit = true
+ if len(vetFlags) > 0 {
+ work.VetExplicit = true
+ }
if vetTool != "" {
var err error
work.VetTool, err = filepath.Abs(vetTool)
diff --git a/src/cmd/go/testdata/script/vet_flags.txt b/src/cmd/go/testdata/script/vet_flags.txt
index 6aa1413fa4..f2cf021f62 100644
--- a/src/cmd/go/testdata/script/vet_flags.txt
+++ b/src/cmd/go/testdata/script/vet_flags.txt
@@ -6,6 +6,17 @@ go vet -n -unreachable=false encoding/binary
stderr '-unreachable=false'
! stderr '-unsafeptr=false'
+# Issue 37030: "go vet <std package>" without other flags should disable the
+# unsafeptr check by default.
+go vet -n encoding/binary
+stderr '-unsafeptr=false'
+! stderr '-unreachable=false'
+
+# However, it should be enabled if requested explicitly.
+go vet -n -unsafeptr encoding/binary
+stderr '-unsafeptr'
+! stderr '-unsafeptr=false'
+
[short] stop
env GOCACHE=$WORK/gocache
env GOTMPDIR=$WORK/tmp
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index de363408e7..5f92e7480e 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -62,9 +62,10 @@
// Allocating and freeing a large object uses the mheap
// directly, bypassing the mcache and mcentral.
//
-// Free object slots in an mspan are zeroed only if mspan.needzero is
-// false. If needzero is true, objects are zeroed as they are
-// allocated. There are various benefits to delaying zeroing this way:
+// If mspan.needzero is false, then free object slots in the mspan are
+// already zeroed. Otherwise if needzero is true, objects are zeroed as
+// they are allocated. There are various benefits to delaying zeroing
+// this way:
//
// 1. Stack frame allocation can avoid zeroing altogether.
//
diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go
index 93f461b07a..88ba0f0242 100644
--- a/src/testing/benchmark.go
+++ b/src/testing/benchmark.go
@@ -179,6 +179,7 @@ func (b *B) ReportAllocs() {
func (b *B) runN(n int) {
benchmarkLock.Lock()
defer benchmarkLock.Unlock()
+ defer b.runCleanup(normalPanic)
// Try to get a comparable environment for each run
// by clearing garbage from previous runs.
runtime.GC()
diff --git a/src/testing/sub_test.go b/src/testing/sub_test.go
index 3dc30ee72e..95f8220f81 100644
--- a/src/testing/sub_test.go
+++ b/src/testing/sub_test.go
@@ -613,6 +613,46 @@ func TestBRun(t *T) {
t.Errorf("MemBytes was %v; want %v", got, 2*bufSize)
}
},
+ }, {
+ desc: "cleanup is called",
+ f: func(b *B) {
+ var calls, cleanups, innerCalls, innerCleanups int
+ b.Run("", func(b *B) {
+ calls++
+ b.Cleanup(func() {
+ cleanups++
+ })
+ b.Run("", func(b *B) {
+ b.Cleanup(func() {
+ innerCleanups++
+ })
+ innerCalls++
+ })
+ work(b)
+ })
+ if calls == 0 || calls != cleanups {
+ t.Errorf("mismatched cleanups; got %d want %d", cleanups, calls)
+ }
+ if innerCalls == 0 || innerCalls != innerCleanups {
+ t.Errorf("mismatched cleanups; got %d want %d", cleanups, calls)
+ }
+ },
+ }, {
+ desc: "cleanup is called on failure",
+ failed: true,
+ f: func(b *B) {
+ var calls, cleanups int
+ b.Run("", func(b *B) {
+ calls++
+ b.Cleanup(func() {
+ cleanups++
+ })
+ b.Fatalf("failure")
+ })
+ if calls == 0 || calls != cleanups {
+ t.Errorf("mismatched cleanups; got %d want %d", cleanups, calls)
+ }
+ },
}}
for _, tc := range testCases {
var ok bool