commit | 149b75d91d473c689bca1aa448862e6761ba4783 | [log] [tgz] |
---|---|---|
author | Jonathan Amsterdam <jba@google.com> | Thu Oct 22 10:34:53 2020 -0400 |
committer | Jonathan Amsterdam <jba@google.com> | Mon Oct 26 14:36:12 2020 +0000 |
tree | 130bdca0329b9f3a0e4b2826f93d3219bcc99ae9 | |
parent | 97155571c30b6b98844a4d7ddd5ea58f896ae50e [diff] |
internal/godoc/codec: preserve field numbers across changes Using field numbers in the encoding instead of names means that the numbers can change if the struct changes. This CL addresses that problem. Here is how the problem can happen: 1. An encoder and decoder for a struct are created. 2. A new struct field is added in the middle, or the existing fields are rearranged. 3. A new encoder and decoder are built. 4. The old decoder from step 1 attempts to decode a struct encoded with the new encoder. The problem is not just that there is a new field--the decoder can handle that, by skipping its value. The problem is that the field numbers of existing fields changed in step 2. For example, if we start with type S struct { A, B int } and then decide to swap the fields: type S struct { B, A int } then the old decoder in step 5, still using the field numbers 0 for A and 1 for B, will put the value of A into B and vice versa. We address this by remembering the field numbers in the generated file, in a comment. When re-generating the file, we read the comment and preserve the numbers. Change-Id: I097b76d71773e358be00308d789dcf4aa4e54230 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/264599 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
Pkg.go.dev is a website for discovering and evaluating Go packages and modules.
You can check it out at https://pkg.go.dev.
Pkg.go.dev launched in November 2019, and is currently under active development by the Go team.
Here's what we are currently working on:
Design updates: We have some design changes planned for pkg.go.dev, to address UX feedback that we have received. You can expect a more cohesive search and navigation experience coming soon. We plan to share these designs for feedback once they are ready.
Godoc.org redirect: Longer term, we are working towards redirecting godoc.org traffic to pkg.go.dev. We know that there are features available on godoc.org that users want to see on pkg.go.dev, and we want to ensure that we address these. We’ve been keeping track of issues related to redirecting godoc.org traffic on Go issue #39144. These issues will be prioritized in the next few months. We also plan to continue improving our license detection algorithm.
Search improvements: We’ll be improving our search experience based on feedback in Go issue #37810, to make it easier for users to find the dependencies they are looking for and make better decisions around which ones to import.
We encourage everyone to begin using pkg.go.dev today for all of their needs and to file feedback! You can redirect all of your requests from godoc.org to pkg.go.dev, by clicking Always use pkg.go.dev
at the top of any page on godoc.org.
If you want to report a bug or have a feature suggestion, please first check the known issues to see if your issue is already being discussed. If an issue does not already exist, feel free to file an issue.
For answers to frequently asked questions, see go.dev/about.
You can also chat with us on the #tools slack channel on the Gophers slack.
We would love your help!
Our canonical Git repository is located at go.googlesource.com/pkgsite. There is a mirror of the repository at github.com/golang/pkgsite.
To contribute, please read our contributing guide.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.