_content/doc/tutorial/json: add encoding/json/v2 tutorial Add a tutorial introducing working with JSON in Go, using encoding/json/v2. This tutorial is a direct descendant of the https://go.dev/blog/json, which was the previous canonical introduction to working with JSON. By placing this a tutorial outside of the blog, it can be a living document, updated over time as things change. On the other hand, a blog post is better as a snapshot in time. The old blog post is left in place, but with a note pointing to the newer tutorial. Most of the changes from the original blog post are pretty minor. Links point to encoding/json/v2 instead of encoding/json. References to `interface{}` are updated to `any` through. The reference to net/rpc/jsonrpc as an example of JSON code is removed, as that package doesn't use v2. I don't have a good alternative to link to. The biggest change is the json.Encoder/json.Decoder section. This section previously served three purposes: (1) show how to marshal/unmarshal with an io.Reader/io.Writer, (2) show how to unmarshal a sequence of distinct JSON objects, and (3) show to mutate a JSON object. (1) is the most important and I've replaced with a short section describing MarshalWrite/UnmarshalRead. (2) and (3) are, IMO, much more niche. I could add some jsontext examples, but I'm not convinced these are important enough to include in an introductory blog post. I've replaced those with an overview of custom marshalers, as I think it's important to introduce users to how to provide custom marshaling when the defaults are not sufficient. For golang/go#71497. Change-Id: Ia24de4c6c8f5c5c3501d7cb35968fe2e6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/website/+/813440 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
This repo holds content and serving programs for the go.dev and golang.org web sites.
Content is in _content/ (go.dev) and tour/ (go.dev/tour). Server code is in cmd/ and internal/.
To run the combined go.dev+golang.org server to preview local content changes, use:
go run ./cmd/golangorg
The supporting programs cmd/admingolangorg and cmd/googlegolangorg are the servers for admin.golang.org and google.golang.org. (They do not use the _content/ directories.)
Each command directory has its own README.md explaining deployment.
This repository uses eslint to format JS and TS files, and stylelint to format CSS files.
See also:
It is encouraged that all JS, TS, and CSS code be run through formatters before submitting a change. However, it is not a strict requirement enforced by CI.
./npm install./npx eslint [options] [file] [dir]
./npx stylelint [input] [options]
TypeScript files served from _content are transformed into JavaScript. Reference .ts files in html templates as module code.
<script type="module" src="/ts/filename.ts">
Write unit tests for TypeScript code using the jest testing framework.
./npx jest [TestPathPattern]
Each time a CL is reviewed and submitted, the code is deployed to App Engine. See cmd/golangorg/README.md for details.
This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.
The git repository is https://go.googlesource.com/website.
The main issue tracker for the website repository is located at https://go.dev/issues. Prefix your issue with “x/website:” in the subject line, so it is easy to find.