1
0
mirror of https://github.com/golang/go synced 2024-11-07 08:26:16 -07:00
Commit Graph

12 Commits

Author SHA1 Message Date
Kevin Burke
bb09f8a29b time: make time.Time print a valid Go string with %#v
Previously calling fmt.Sprintf("%#v", t) on a time.Time value would
yield a result like:

    time.Time{wall:0x0, ext:63724924180, loc:(*time.Location)(nil)}

which does not compile when embedded in a Go program, and does not
tell you what value is represented at a glance.

This change adds a GoString method that returns much more legible
output:

    "time.Date(2009, time.February, 5, 5, 0, 57, 12345600, time.UTC)"

which gives you more information about the time.Time and also can be
usefully embedded in a Go program without additional work.

Update Quote() to hex escape non-ASCII characters (copying logic
from strconv), which makes it safer to embed them in the output of
GoString().

Fixes #39034.

Change-Id: Ic985bafe4e556f64e82223c643f65143c9a45c3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/267017
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
2021-05-02 20:59:26 +00:00
Bryan C. Mills
eb71887b99 cmd/go: prune go.mod and go.sum files from vendored dependencies
Fixes #42970

Change-Id: I79246ef7fc16ae05c8e7b40ffb239a61f6415447
Reviewed-on: https://go-review.googlesource.com/c/go/+/315410
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-30 18:14:18 +00:00
Bryan C. Mills
c3365ad5f2 cmd/go: annotate versions in vendor/modules.txt
In order to prevent edit wars with previous cmd/go releases,
the new version annotations are only included if the main module
specifies 'go 1.17' or higher.

Fixes #36876

Change-Id: Iba15e47dd1ac2c16d754679a9b501db4069fa250
Reviewed-on: https://go-review.googlesource.com/c/go/+/315409
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-30 18:07:24 +00:00
Bryan C. Mills
7dedc237c5 cmd/go: smooth out upgrade paths for lazy loading
This change adds two possible upgrade paths for lazy loading:

1. Run 'go mod tidy -go=1.17'.

2. Starting in a module with no existing 'go' directive,
   run any 'go' command that updates the go.mod file.

In the latter case, commands other than 'go mod tidy'
may leave the go.mod file *very* untidy if it had non-trivial
dependencies. (The 'go' invocation will promote all
implicit eager dependencies to explicit lazy ones,
which preserves the original module graph — most of which is
not actually relevant.)

'go mod tidy -go=1.17' can be used to enable lazy loading without
accidentally downgrading existing transitive dependencies.

'go mod tidy -go=1.16' can be used to disable lazy loading and clear
away redundant roots in a single step (if reducing the go version), or
to prune away dependencies of tests-of-external-tests (if increasing
the go version).

'go mod tidy -go=1.15' can be used to add dependencies of
tests-of-external-tests, although there isn't much point to that.

DO NOT MERGE

This change still needs an explicit test and a release note.

Fixes #45094
For #36460

Change-Id: I68f057e39489dfd6a667cd11dc1e320c1ee1aec1
Reviewed-on: https://go-review.googlesource.com/c/go/+/315210
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-30 18:06:46 +00:00
Bryan C. Mills
9a81702b97 cmd/go: enable lazy loading
This change activates the dormant “lazy loading” codepaths added in CL
265777 and its predecessors. Dependencies of modules that declare 'go
1.17' or higher are loaded lazily, and the dependencies in the go.mod
file maintain additional invariants to support more efficient lazy
loading for downstream dependent modules.

See https://golang.org/design/36460-lazy-module-loading for the
detailed design.

For #36460

Change-Id: Ic12ee7842aef9580357fcf8909d87654fcb2ad12
Reviewed-on: https://go-review.googlesource.com/c/go/+/314634
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-30 18:05:18 +00:00
Jay Conrod
cde92846e2 doc: add release note for module deprecation
Fixes #40357

Change-Id: I876edd7364530b77343ebcdd4032390493f8d031
Reviewed-on: https://go-review.googlesource.com/c/go/+/309549
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-16 14:13:38 +00:00
Changkun Ou
972e883925 runtime/cgo: add Handle for managing (c)go pointers
A non-trivial Cgo program may need to use callbacks and interact with
go objects per goroutine. Because of the rules for passing pointers
between Go and C, such a program needs to store handles to associated
Go values. This often causes much extra effort to figure out a way to
correctly deal with: 1) map collision; 2) identifying leaks and 3)
concurrency.

This CL implements a Handle representation in runtime/cgo package, and
related methods such as Value, Delete, etc. which allows Go users can
use a standard way to handle the above difficulties.

In addition, the CL allows a Go value to have multiple handles, and the
NewHandle always returns a different handle compare to the previously
returned handles. In comparison, CL 294670 implements a different
behavior of NewHandle that returns a unique handle when the Go value is
referring to the same object.

Benchmark:
name                      time/op
Handle/non-concurrent-16  487ns ± 1%
Handle/concurrent-16      674ns ± 1%

Fixes #37033

Change-Id: I0eadb9d44332fffef8fb567c745246a49dd6d4c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/295369
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Zhang <cherryyz@google.com>
2021-04-06 23:39:42 +00:00
Bryan C. Mills
3b0d28808d cmd/go: assume Go 1.16 instead of Go 1.11 for dependencies that lack explicit 'go' directives
Fixes #45109
Updates #44976
Updates #36876

Change-Id: Icb00f8b6e0d4e076d82da1697e7058b9e7603916
Reviewed-on: https://go-review.googlesource.com/c/go/+/303229
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-03-19 19:59:56 +00:00
Bryan C. Mills
7e00049b55 cmd/go: only add a 'go' directive to the main module when the go.mod file will be written
Then, write the 'go.mod' file with that version before further
processing. That way, if the command errors out due to a change in
behavior, the reason for the change in behavior will be visible in the
file diffs.

If the 'go.mod' file cannot be written (due to -mod=readonly or
-mod=vendor), assume Go 1.11 instead of the current Go release.
(cmd/go has added 'go' directives automatically, including in 'go mod
init', since Go 1.12.)

For #44976

Change-Id: If9d4af557366f134f40ce4c5638688ba3bab8380
Reviewed-on: https://go-review.googlesource.com/c/go/+/302051
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-03-17 21:24:05 +00:00
Johan Brandhorst
860704317e crypto/tls: add HandshakeContext method to Conn
Adds the (*tls.Conn).HandshakeContext method. This allows
us to pass the context provided down the call stack to
eventually reach the tls.ClientHelloInfo and
tls.CertificateRequestInfo structs.
These contexts are exposed to the user as read-only via Context()
methods.

This allows users of (*tls.Config).GetCertificate and
(*tls.Config).GetClientCertificate to use the context for
request scoped parameters and cancellation.

Replace uses of (*tls.Conn).Handshake with (*tls.Conn).HandshakeContext
where appropriate, to propagate existing contexts.

Fixes #32406

Change-Id: I259939c744bdc9b805bf51a845a8bc462c042483
Reviewed-on: https://go-review.googlesource.com/c/go/+/295370
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2021-03-16 14:05:45 +00:00
witchard
312fd9937d cmd/go: remove -insecure flag on go get
Resolves #37519

Change-Id: Iba675a180b0e61b12835cdb6ecd4c6dc61e0605c
GitHub-Last-Rev: aa018af6f8
GitHub-Pull-Request: golang/go#44724
Reviewed-on: https://go-review.googlesource.com/c/go/+/297709
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-03-02 21:49:08 +00:00
Dmitri Shuralyov
74903553bc doc: start draft go1.17 release notes, move go1.16 to x/website
This template is based on CL 248198 and previous ones like it.
Continue to eagerly include often-used sections, and clarify that
the TODO is about completing the section, or removing if it turns
out not to be needed.

Move the Go 1.16 release notes to x/website, since that's the new
home for past Go release notes as of CL 291711. They're added to
x/website in CL 295249.

'relnote -html' does not report any CLs with RELNOTE annotations
since 2021/02/01.

For #44513.
Updates #40700.

Change-Id: Idd389335500ec4dec2764cbbaa385918cc8a79ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/295209
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2021-02-23 21:45:12 +00:00