Skip to content
forked from golang/go

Commit

Permalink
Merge pull request #137 from golang/master
Browse files Browse the repository at this point in the history
Sync Fork from Upstream Repo
  • Loading branch information
sthagen committed Feb 1, 2020
2 parents 0d709ca + cdb7fd6 commit 80419c5
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 45 deletions.
1 change: 0 additions & 1 deletion api/go1.14.txt
Expand Up @@ -150,7 +150,6 @@ pkg go/doc, type Example struct, Suffix string
pkg go/doc, type Func struct, Examples []*Example
pkg go/doc, type Package struct, Examples []*Example
pkg go/doc, type Type struct, Examples []*Example
pkg go/types, method (*Checker) LookupFieldOrMethod(Type, bool, *Package, string) (Object, []int, bool)
pkg hash/maphash, func MakeSeed() Seed
pkg hash/maphash, method (*Hash) BlockSize() int
pkg hash/maphash, method (*Hash) Reset()
Expand Down
234 changes: 204 additions & 30 deletions doc/go1.14.html
Expand Up @@ -304,10 +304,9 @@ <h4 id="module-downloading">Module downloading</h4>
graphic characters and spaces.
</p>

<h4 id="go.mod">Testing</h4>
<!-- golang.org/issue/24929 -->
<h4 id="go-test">Testing</h4>

<p>
<p><!-- golang.org/issue/24929 -->
<code>go test -v</code> now streams <code>t.Log</code> output as it happens,
rather than at the end of all tests.
</p>
Expand Down Expand Up @@ -429,6 +428,14 @@ <h2 id="library">Core library</h2>
TODO
</p>

<h3 id="minor_library_changes">Minor changes to the library</h3>

<p>
As always, there are various minor changes and updates to the library,
made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
in mind.
</p>

<dl id="hash/maphash"><dt><a href="/pkg/hash/maphash">hash/maphash</a></dt>
<dd>
<p><!-- CL 186877 -->
Expand All @@ -446,19 +453,61 @@ <h2 id="library">Core library</h2>
<dl id="crypto/tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt>
<dd>
<p><!-- CL 191976 -->
TODO: <a href="https://golang.org/cl/191976">https://golang.org/cl/191976</a>: remove SSLv3 support
Support for SSL version 3.0 (SSLv3) has been removed. Note that SSLv3 is the
<a href="https://tools.ietf.org/html/rfc7568">cryptographically broken</a>
protocol predating TLS.
</p>

<p><!-- CL 191999 -->
TODO: <a href="https://golang.org/cl/191999">https://golang.org/cl/191999</a>: remove TLS 1.3 opt-out
TLS 1.3 can't be disabled via the <code>GODEBUG</code> environment
variable anymore. Use the
<a href="/pkg/crypto/tls/#Config.MaxVersion"><code>Config.MaxVersion</code></a>
field to configure TLS versions.
</p>

<p><!-- CL 205059 -->
When multiple certificate chains are provided through the
<a href="/pkg/crypto/tls/#Config.Certificates"><code>Config.Certificates</code></a>
field, the first one compatible with the peer is now automatically
selected. This allows for example providing an ECDSA and an RSA
certificate, and letting the package automatically select the best one.
Note that the performance of this selection is going to be poor unless the
<a href="/pkg/crypto/tls/#Certificate.Leaf"><code>Certificate.Leaf</code></a>
field is set.
</p>

<p><!-- CL 175517 -->
The new <a href="/pkg/crypto/tls/#CipherSuites"><code>CipherSuites</code></a>
and <a href="/pkg/crypto/tls/#InsecureCipherSuites"><code>InsecureCipherSuites</code></a>
functions return a list of currently implemented cipher suites.
The new <a href="/pkg/crypto/tls/#CipherSuiteName"><code>CipherSuiteName</code></a>
function returns a name for a cipher suite ID.
</p>

<p><!-- CL 205058, 205057 -->
The new <a href="/pkg/crypto/tls/#ClientHelloInfo.SupportsCertificate">
<code>(*ClientHelloInfo).SupportsCertificate</code></a> and
<a href="/pkg/crypto/tls/#CertificateRequestInfo.SupportsCertificate">
<code>(*CertificateRequestInfo).SupportsCertificate</code></a>
methods expose whether a peer supports a certain certificate.
</p>

<p><!-- CL 174329 -->
The <code>tls</code> package no longer supports NPN and now only
supports ALPN. In previous releases it supported both. There are
no API changes and code should function identically as before.
Most other clients & servers have already removed NPN support in
favor of the standardized ALPN.
The <code>tls</code> package no longer supports the legacy Next Protocol
Negotiation (NPN) extension and now only supports ALPN. In previous
releases it supported both. There are no API changes and applications
should function identically as before. Most other clients and servers have
already removed NPN support in favor of the standardized ALPN.
</p>

<p><!-- CL 205063, 205062 -->
RSA-PSS signatures are now used when supported in TLS 1.2 handshakes. This
won't affect most applications, but custom
<a href="/pkg/crypto/tls/#Certificate.PrivateKey"><code>Certificate.PrivateKey</code></a>
implementations that don't support RSA-PSS signatures will need to use the new
<a href="/pkg/crypto/tls/#Certificate.SupportedSignatureAlgorithms">
<code>Certificate.SupportedSignatureAlgorithms</code></a>
field to disable them.
</p>

</dl><!-- crypto/tls -->
Expand All @@ -473,6 +522,14 @@ <h2 id="library">Core library</h2>

<dl id="encoding/json"><dt><a href="/pkg/encoding/json/">encoding/json</a></dt>
<dd>
<p><!-- CL 200677 -->
The <a href="/pkg/encoding/json/#Decoder"><code>Decoder</code></a>
type supports a new
method <a href="/pkg/encoding/json/#Decoder.InputOffset"><code>InputOffset</code></a>
that returns the input stream byte offset of the current
decoder position.
</p>

<p><!-- CL 200217 -->
<a href="/pkg/encoding/json/#Compact"><code>Compact</code></a> no longer
escapes the <code>U+2028</code> and <code>U+2029</code> characters, which
Expand All @@ -482,6 +539,30 @@ <h2 id="library">Core library</h2>

</dl><!-- encoding/json -->

<dl id="go/build"><dt><a href="/pkg/go/build/">go/build</a></dt>
<dd>
<p><!-- CL 203820, 211657 -->
The <a href="/pkg/go/build/#Context"><code>Context</code></a>
type has a new field <code>Dir</code> which may be used to set
the working directory for the build.
The default is the current directory of the running process.
In module mode, this is used to locate the main module.
</p>
</dd>
</dl><!-- go/build -->

<dl id="log"><dt><a href="/pkg/log/">log</a></dt>
<dd>
<p><!-- CL 186182 -->
The
new <a href="https://tip.golang.org/pkg/log/#pkg-constants"><code>Lmsgprefix</code></a>
flag may be used to tell the logging functions to emit the
optional output prefix immediately before the log message rather
than at the start of the line.
</p>
</dd>
</dl><!-- log -->

<dl id="go/doc"><dt><a href="/go/doc/">go/doc</a></dt>
<dd>
<p><!-- CL 204830 -->
Expand All @@ -502,14 +583,6 @@ <h2 id="library">Core library</h2>
</dd>
</dl><!-- go/doc -->

<dl id="mime"><dt><a href="/pkg/mime/">mime</a></dt>
<dd>
<p><!-- CL 186927 -->
TODO: <a href="https://golang.org/cl/186927">https://golang.org/cl/186927</a>: update type of .js and .mjs files to text/javascript
</p>

</dl><!-- mime -->

<dl id="math"><dt><a href="/pkg/math/">math</a></dt>
<dd>
<p><!-- CL 127458 -->
Expand All @@ -525,13 +598,98 @@ <h2 id="library">Core library</h2>
<dl id="math/big"><dt><a href="/pkg/math/big">math/big</a></dt>
<dd>
<p><!-- CL 164972 -->
The <a href="/pkg/math/big/#GCD"><code>GCD</code></a> function
The <a href="/pkg/math/big/#Int.GCD"><code>GCD</code></a> method
now allows the inputs <code>a</code> and <code>b</code> to be
zero or negative.
</p>

</dl><!-- math/big -->

<dl id="math/bits"><dt><a href="/pkg/math/bits/">math/bits</a></dt>
<dd>
<p><!-- CL 197838 -->
The new functions
<a href="/pkg/math/bits/#Rem"><code>Rem</code></a>,
<a href="/pkg/math/bits/#Rem32"><code>Rem32</code></a>, and
<a href="/pkg/math/bits/#Rem64"><code>Rem64</code></a>
support computing a remainder even when the quotient overflows.
</p>
</dd>
</dl><!-- math/bits -->

<dl id="mime"><dt><a href="/pkg/mime/">mime</a></dt>
<dd>
<p><!-- CL 186927 -->
The default type of <code>.js</code> and <code>.mjs</code> files
is now <code>text/javascript</code> rather
than <code>application/javascript</code>.
This is in accordance
with <a href="https://datatracker.ietf.org/doc/draft-ietf-dispatch-javascript-mjs/">an
IETF draft</a> that treats <code>application/javascript</code> as obsolete.
</p>

</dl><!-- mime -->

<dl id="mime/multipart"><dt><a href="/pkg/mime/multipart/">mime/multipart</a></dt>
<dd>
<p>
The
new <a href="/pkg/mime/multipart/#Reader"><code>Reader</code></a>
method <a href="/pkg/mime/multipart/#Reader.NextRawPart"><code>NextRawPart</code></a>
supports fetching the next MIME part without transparently
decoding <code>quoted-printable</code> data.
</p>
</dd>
</dl><!-- mime/multipart -->

<dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
<dd>
<p><!-- CL 200760 -->
The new <a href="/pkg/net/http/#Header"><code>Header</code></a>
method <a href="/pkg/net/http/#Header.Values"><code>Values</code></a>
can be used to fetch all values associated with a
canonicalized key.
</p>

<p><!-- CL 61291 -->
The
new <a href="/pkg/net/http/#Transport"><code>Transport</code></a>
field <a href="/pkg/net/http/#Transport.DialTLSContext"><code>DialTLSContext</code></a>
can be used to specify an optional dial function for creating
TLS connections for non-proxied HTTPS requests.
This new field can be used instead
of <a href="/pkg/net/http/#Transport.DialTLS"><code>DialTLS</code></a>,
which is now considered deprecated; <code>DialTLS</code> will
continue to work, but new code should
use <code>DialTLSContext</code>, which allows the transport to
cancel dials as soon as they are no longer needed.
</p>
</dd>
</dl><!-- net/http -->

<dl id="net/http/httptest"><dt><a href="/net/http/httptest/">net/http/httptest</a></dt>
<dd>
<p><!-- CL 201557 -->
The
new <a href="/pkg/net/http/httptest/#Server"><code>Server</code></a>
field <a href="/pkg/net/http/httptest/#Server.EnableHTTP2"><code>EnableHTTP2</code></a>
supports enabling HTTP/2 on the test server.
</p>
</dd>
</dl><!-- net/http/httptest -->

<dl id="net/textproto"><dt><a href="/pkg/net/textproto/">net/textproto</a></dt>
<dd>
<p><!-- CL 200760 -->
The
new <a href="/pkg/net/textproto/#MIMEHeader"><code>MIMEHeader</code></a>
method <a href="/pkg/net/textproto/#MIMEHeader.Values"><code>Values</code></a>
can be used to fetch all values associated with a canonicalized
key.
</p>
</dd>
</dl><!-- net/textproto -->

<dl id="plugin"><dt><a href="/pkg/plugin/">plugin</a></dt>
<dd>
<p><!-- CL 191617 -->
Expand Down Expand Up @@ -593,6 +751,23 @@ <h2 id="library">Core library</h2>

</dl><!-- signal -->

<dl id="strconv"><dt><a href="/pkg/strconv/">strconv</a></dt>
<dd>
<p>
The <a href="/pkg/strconv/#NumError"><code>NumError</code></a>
type now has
an <a href="/pkg/strconv/#NumError.Unwrap"><code>Unwrap</code></a>
method that may be used to retrieve the reason that a conversion
failed.
This supports using <code>NumError</code> values
with <a href="/pkg/errors/#Is"><code>errors.Is</code></a> to see
if the underlying error
is <a href="/pkg/strconv/#pkg-variables"><code>strconv.ErrRange</code></a>
or <a href="/pkg/strconv/#pkg-variables"><code>strconv.ErrSyntax</code></a>.
</p>
</dd>
</dl><!-- strconv -->

<dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
<dd>
<p><!-- CL 200577 -->
Expand All @@ -615,14 +790,13 @@ <h2 id="library">Core library</h2>
</p>
</dl><!-- testing -->

<h3 id="minor_library_changes">Minor changes to the library</h3>

<p>
As always, there are various minor changes and updates to the library,
made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
in mind.
</p>

<p>
TODO
</p>
<dl id="unicode"><dt><a href="/pkg/unicode/">unicode</a></dt>
<dd>
<p>
The <a href="/pkg/unicode/"><code>unicode</code></a> package and associated
support throughout the system has been upgraded from Unicode 11.0 to
<a href="https://www.unicode.org/versions/Unicode12.0.0/">Unicode 12.0</a>,
which adds 554 new characters, including four new scripts, and 61 new emoji.
</p>
</dd>
</dl><!-- unicode -->
2 changes: 1 addition & 1 deletion src/go/types/builtins.go
Expand Up @@ -559,7 +559,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b

base := derefStructPtr(x.typ)
sel := selx.Sel.Name
obj, index, indirect := check.LookupFieldOrMethod(base, false, check.pkg, sel)
obj, index, indirect := check.lookupFieldOrMethod(base, false, check.pkg, sel)
switch obj.(type) {
case nil:
check.invalidArg(x.pos(), "%s has no single field %s", base, sel)
Expand Down
2 changes: 1 addition & 1 deletion src/go/types/call.go
Expand Up @@ -370,7 +370,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) {
goto Error
}

obj, index, indirect = check.LookupFieldOrMethod(x.typ, x.mode == variable, check.pkg, sel)
obj, index, indirect = check.lookupFieldOrMethod(x.typ, x.mode == variable, check.pkg, sel)
if obj == nil {
switch {
case index != nil:
Expand Down
20 changes: 10 additions & 10 deletions src/go/types/lookup.go
Expand Up @@ -33,19 +33,19 @@ package types
// the method's formal receiver base type, nor was the receiver addressable.
//
func LookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) {
return (*Checker)(nil).LookupFieldOrMethod(T, addressable, pkg, name)
return (*Checker)(nil).lookupFieldOrMethod(T, addressable, pkg, name)
}

// Internal use of Checker.LookupFieldOrMethod: If the obj result is a method
// Internal use of Checker.lookupFieldOrMethod: If the obj result is a method
// associated with a concrete (non-interface) type, the method's signature
// may not be fully set up. Call Checker.objDecl(obj, nil) before accessing
// the method's type.
// TODO(gri) Now that we provide the *Checker, we can probably remove this
// caveat by calling Checker.objDecl from LookupFieldOrMethod. Investigate.
// caveat by calling Checker.objDecl from lookupFieldOrMethod. Investigate.

// LookupFieldOrMethod is like the external version but completes interfaces
// lookupFieldOrMethod is like the external version but completes interfaces
// as necessary.
func (check *Checker) LookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) {
func (check *Checker) lookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) {
// Methods cannot be associated to a named pointer type
// (spec: "The type denoted by T is called the receiver base type;
// it must not be a pointer or interface type and it must be declared
Expand All @@ -55,24 +55,24 @@ func (check *Checker) LookupFieldOrMethod(T Type, addressable bool, pkg *Package
// not have found it for T (see also issue 8590).
if t, _ := T.(*Named); t != nil {
if p, _ := t.underlying.(*Pointer); p != nil {
obj, index, indirect = check.lookupFieldOrMethod(p, false, pkg, name)
obj, index, indirect = check.rawLookupFieldOrMethod(p, false, pkg, name)
if _, ok := obj.(*Func); ok {
return nil, nil, false
}
return
}
}

return check.lookupFieldOrMethod(T, addressable, pkg, name)
return check.rawLookupFieldOrMethod(T, addressable, pkg, name)
}

// TODO(gri) The named type consolidation and seen maps below must be
// indexed by unique keys for a given type. Verify that named
// types always have only one representation (even when imported
// indirectly via different packages.)

// lookupFieldOrMethod should only be called by LookupFieldOrMethod and missingMethod.
func (check *Checker) lookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) {
// rawLookupFieldOrMethod should only be called by lookupFieldOrMethod and missingMethod.
func (check *Checker) rawLookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) {
// WARNING: The code in this function is extremely subtle - do not modify casually!
// This function and NewMethodSet should be kept in sync.

Expand Down Expand Up @@ -297,7 +297,7 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method *

// A concrete type implements T if it implements all methods of T.
for _, m := range T.allMethods {
obj, _, _ := check.lookupFieldOrMethod(V, false, m.pkg, m.name)
obj, _, _ := check.rawLookupFieldOrMethod(V, false, m.pkg, m.name)

// we must have a method (not a field of matching function type)
f, _ := obj.(*Func)
Expand Down

0 comments on commit 80419c5

Please sign in to comment.