aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2018-05-25 15:07:15 -0400
committerFilippo Valsorda <filippo@golang.org>2018-05-26 06:50:14 +0000
commit48ee689f19c0b27c8a7b2de9d3b26fe6c0d4fa5d (patch)
tree0c0b6ac407011657fa7b057a6776332d7fabbd68
parent09fa131c99da0ef9f78c9f4f6cd955237ccc01cd (diff)
downloadgo-48ee689f19c0b27c8a7b2de9d3b26fe6c0d4fa5d.tar.gz
go-48ee689f19c0b27c8a7b2de9d3b26fe6c0d4fa5d.zip
[release-branch.go1.10] doc: sync with master
A number of changes were applied to documentation in master, including a wide rewrite of the contribution guide. Backport them all to get them deployed on golang.org. $ git ch master -- doc $ git show-ref master 88756931d0a6e23aeaf61caa6a7363ac04be2063 refs/heads/master Change-Id: Ib45ff191f3b60723aa4421113992289c37d144aa Reviewed-on: https://go-review.googlesource.com/114503 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org> Run-TryBot: Andrew Bonventre <andybons@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--doc/articles/wiki/index.html12
-rw-r--r--doc/asm.html65
-rw-r--r--doc/contribute.html1276
-rw-r--r--doc/devel/release.html8
-rw-r--r--doc/effective_go.html3
-rw-r--r--doc/go1.10.html4
-rw-r--r--doc/go_faq.html66
-rw-r--r--doc/go_spec.html22
-rw-r--r--doc/install-source.html2
-rw-r--r--doc/install.html12
-rw-r--r--doc/progs/error2.go4
-rw-r--r--doc/progs/error3.go2
-rw-r--r--doc/root.html6
13 files changed, 938 insertions, 544 deletions
diff --git a/doc/articles/wiki/index.html b/doc/articles/wiki/index.html
index 3e0d532d7f..b7ab2cc622 100644
--- a/doc/articles/wiki/index.html
+++ b/doc/articles/wiki/index.html
@@ -269,6 +269,12 @@ view a wiki page. It will handle URLs prefixed with "/view/".
{{code "doc/articles/wiki/part2.go" `/^func viewHandler/` `/^}/`}}
<p>
+Again, note the use of <code>_</code> to ignore the <code>error</code>
+return value from <code>loadPage</code>. This is done here for simplicity
+and generally considered bad practice. We will attend to this later.
+</p>
+
+<p>
First, this function extracts the page title from <code>r.URL.Path</code>,
the path component of the request URL.
The <code>Path</code> is re-sliced with <code>[len("/view/"):]</code> to drop
@@ -283,12 +289,6 @@ HTML, and writes it to <code>w</code>, the <code>http.ResponseWriter</code>.
</p>
<p>
-Again, note the use of <code>_</code> to ignore the <code>error</code>
-return value from <code>loadPage</code>. This is done here for simplicity
-and generally considered bad practice. We will attend to this later.
-</p>
-
-<p>
To use this handler, we rewrite our <code>main</code> function to
initialize <code>http</code> using the <code>viewHandler</code> to handle
any requests under the path <code>/view/</code>.
diff --git a/doc/asm.html b/doc/asm.html
index 3a05d46aeb..f2f8fad576 100644
--- a/doc/asm.html
+++ b/doc/asm.html
@@ -739,6 +739,13 @@ The ARM64 port is in an experimental state.
</p>
<p>
+<code>R18</code> is the "platform register", reserved on the Apple platform.
+<code>R27</code> and <code>R28</code> are reserved by the compiler and linker.
+<code>R29</code> is the frame pointer.
+<code>R30</code> is the link register.
+</p>
+
+<p>
Instruction modifiers are appended to the instruction following a period.
The only modifiers are <code>P</code> (postincrement) and <code>W</code>
(preincrement):
@@ -752,11 +759,61 @@ Addressing modes:
<ul>
<li>
-<code>(R5, R6)</code>: Register pair for <code>LDP</code>/<code>STP</code>.
+<code>R0-&gt;16</code>
+<br>
+<code>R0&gt;&gt;16</code>
+<br>
+<code>R0&lt;&lt;16</code>
+<br>
+<code>R0@&gt;16</code>:
+These are the same as on the 32-bit ARM.
+</li>
+
+<li>
+<code>$(8&lt;&lt;12)</code>:
+Left shift the immediate value <code>8</code> by <code>12</code> bits.
+</li>
+
+<li>
+<code>8(R0)</code>:
+Add the value of <code>R0</code> and <code>8</code>.
+</li>
+
+<li>
+<code>(R2)(R0)</code>:
+The location at <code>R0</code> plus <code>R2</code>.
+</li>
+
+<li>
+<code>R0.UXTB</code>
+<br>
+<code>R0.UXTB&lt;&lt;imm</code>:
+<code>UXTB</code>: extract an 8-bit value from the low-order bits of <code>R0</code> and zero-extend it to the size of <code>R0</code>.
+<code>R0.UXTB&lt;&lt;imm</code>: left shift the result of <code>R0.UXTB</code> by <code>imm</code> bits.
+The <code>imm</code> value can be 0, 1, 2, 3, or 4.
+The other extensions include <code>UXTH</code> (16-bit), <code>UXTW</code> (32-bit), and <code>UXTX</code> (64-bit).
+</li>
+
+<li>
+<code>R0.SXTB</code>
+<br>
+<code>R0.SXTB&lt;&lt;imm</code>:
+<code>SXTB</code>: extract an 8-bit value from the low-order bits of <code>R0</code> and sign-extend it to the size of <code>R0</code>.
+<code>R0.SXTB&lt;&lt;imm</code>: left shift the result of <code>R0.SXTB</code> by <code>imm</code> bits.
+The <code>imm</code> value can be 0, 1, 2, 3, or 4.
+The other extensions include <code>SXTH</code> (16-bit), <code>SXTW</code> (32-bit), and <code>SXTX</code> (64-bit).
+</li>
+
+<li>
+<code>(R5, R6)</code>: Register pair for <code>LDAXP</code>/<code>LDP</code>/<code>LDXP</code>/<code>STLXP</code>/<code>STP</code>/<code>STP</code>.
</li>
</ul>
+<p>
+Reference: <a href="/pkg/cmd/internal/obj/arm64">Go ARM64 Assembly Instructions Reference Manual</a>
+</p>
+
<h3 id="ppc64">64-bit PowerPC, a.k.a. ppc64</h3>
<p>
@@ -882,6 +939,12 @@ The value of <code>GOMIPS</code> environment variable (<code>hardfloat</code> or
<code>GOMIPS_hardfloat</code> or <code>GOMIPS_softfloat</code>.
</p>
+<p>
+The value of <code>GOMIPS64</code> environment variable (<code>hardfloat</code> or
+<code>softfloat</code>) is made available to assembly code by predefining either
+<code>GOMIPS64_hardfloat</code> or <code>GOMIPS64_softfloat</code>.
+</p>
+
<h3 id="unsupported_opcodes">Unsupported opcodes</h3>
<p>
diff --git a/doc/contribute.html b/doc/contribute.html
index e5312becbb..d802bd72a1 100644
--- a/doc/contribute.html
+++ b/doc/contribute.html
@@ -3,39 +3,65 @@
}-->
<p>
-The Go project welcomes all contributors. The process of contributing
-to the Go project may be different than many projects you are used to.
-This document is intended as a guide to help you through the contribution
-process. This guide assumes you have a basic understanding of Git and Go.
+The Go project welcomes all contributors.
</p>
<p>
-(Note that the <code>gccgo</code> frontend lives elsewhere;
-see <a href="gccgo_contribute.html">Contributing to gccgo</a>.)
+This document is a guide to help you through the process
+of contributing to the Go project, which is a little different
+from that used by other open source projects.
+We assume you have a basic understanding of Git and Go.
</p>
<p>
-Sensitive security-related issues should be reported to <a href="mailto:security@golang.org">security@golang.org</a>.
+In addition to the information here, the Go community maintains a
+<a href="https://golang.org/wiki/CodeReview">CodeReview</a> wiki page.
+Feel free to contribute to the wiki as you learn the review process.
</p>
-<h1 id="contributor">Becoming a contributor</h1>
+<p>
+Note that the <code>gccgo</code> front end lives elsewhere;
+see <a href="gccgo_contribute.html">Contributing to gccgo</a>.
+</p>
+
+<h2 id="contributor">Becoming a contributor</h2>
+
+<h3>Overview</h3>
<p>
-Before you can contribute to the Go project you need to setup a few prerequisites.
-The Go project uses <a href="https://www.gerritcodereview.com/">Gerrit</a>, an open
-source online tool, to perform all code reviews.
-Gerrit uses your email address as a unique identifier.
-The Go project contributing flow is currently configured to work only with Google Accounts.
-You must go through the following process <em>prior to contributing</em>.
-You only need to do this once per Google Account.
+The first step is registering as a Go contributor and configuring your environment.
+Here is a checklist of the required steps to follow:
</p>
-<h2 id="go-contrib-init">Automatically set up &amp; diagnose your development environment</h2>
+<ul>
+<li>
+<b>Step 0</b>: Decide on a single Google Account you will be using to contribute to Go.
+Use that account for all the following steps and make sure that <code>git</code>
+is configured to create commits with that account's e-mail address.
+</li>
+<li>
+<b>Step 1</b>: <a href="https://cla.developers.google.com/clas">Sign and submit</a> a
+CLA (Contributor License Agreement).
+</li>
+<li>
+<b>Step 2</b>: Configure authentication credentials for the Go Git repository.
+Visit <a href="https://go.googlesource.com/">go.googlesource.com</a>, click
+on "Generate Password" (top right), and follow the instructions.
+</li>
+<li>
+<b>Step 3</b>: Register for Gerrit, the code review tool used by the Go team,
+by <a href="https://go-review.googlesource.com/login/">visiting this page</a>.
+The CLA and the registration need to be done only once for your account.
+</li>
+<li>
+<b>Step 4</b>: Install <code>git-codereview</code> by running
+<code>go get -u golang.org/x/review/git-codereview</code>
+</li>
+</ul>
+
<p>
- The <code>go-contrib-init</code> tool configures and debugs your Go
- development environment, automatically performing many of the steps
- on this page, or telling you what you need to do next. If you wish
- to use it, run:
+If you prefer, there is an automated tool that walks through these steps.
+Just run:
</p>
<pre>
@@ -45,66 +71,61 @@ $ go-contrib-init
</pre>
<p>
- The tool will either set things up, tell you that everything is
- configured, or tell you what steps you need to do manually.
+The rest of this chapter elaborates on these instructions.
+If you have completed the steps above (either manually or through the tool), jump to
+<a href="#making_a_change">Making a change</a>.
</p>
-<h2 id="auth">Configure Git to use Gerrit</h2>
-<p>
-You'll need a web browser and a command line terminal.
-You should already have Git installed.
-</p>
+<h3 id="google_account">Step 0: Select a Google Account</h3>
<p>
-Gerrit uses Google Accounts for authentication.
-If you don't have a Google Account, you can create an account which
-<a href="https://www.google.com/accounts/NewAccount">includes
-a new Gmail email account</a> or create an account associated
-<a href="https://accounts.google.com/SignUpWithoutGmail">with your existing
-email address</a>.
+A contribution to Go is made through a Google account with a specific
+e-mail address.
+Make sure to use the same account throughout the process and
+for all your subsequent contributions.
+You may need to decide whether to use a personal address or a corporate address.
+The choice will depend on who
+will own the copyright for the code that you will be writing
+and submitting.
+You might want to discuss this topic with your employer before deciding which
+account to use.
</p>
-<h3>Step 1: Sign in to googlesource and generate a password</h3>
-
<p>
-Visit <a href="https://go.googlesource.com">go.googlesource.com</a>
-and click on "Generate Password" in the page's top right menu bar.
-You will be redirected to accounts.google.com to sign in.
+Google accounts can either be Gmail e-mail accounts, G-Suite organization accounts, or
+accounts associated with an external e-mail address.
+For instance, if you need to use
+an existing corporate e-mail that is not managed through G-Suite, you can create
+an account associated
+<a href="https://accounts.google.com/SignUpWithoutGmail">with your existing
+e-mail address</a>.
</p>
-<h3>Step 2: Run the provided script</h3>
<p>
-After signing in, you are taken to a page on go.googlesource.com with the title "Configure Git".
-This page contains a personalized script which when run locally will configure git
-to have your unique authentication key.
-This key is paired with one generated server side similar to how ssh keys work.
+You also need to make sure that your Git tool is configured to create commits
+using your chosen e-mail address.
+You can either configure Git globally
+(as a default for all projects), or locally (for a single specific project).
+You can check the current configuration with this command:
</p>
-<p>
-Copy and run this script locally in your command line terminal.
-(On a Windows computer using cmd you should instead follow the instructions
-in the yellow box to run the command. If you are using git-bash use the same
-script as *nix.)
-</p>
+<pre>
+$ git config --global user.email # check current global config
+$ git config user.email # check current local config
+</pre>
<p>
-Your secret authentication token is now in a <code>.gitcookies</code> file
-and Git is configured to use this file.
+To change the configured address:
</p>
-<h3 id="gerrit">Step 3: Register with Gerrit</h3>
+<pre>
+$ git config --global user.email name@example.com # change global config
+$ git config user.email name@example.com # change local config
+</pre>
-<p>
-Now that you have your authentication token, you need to register your
-account with Gerrit.
-To do this, visit <a href="https://go-review.googlesource.com/login/">
-go-review.googlesource.com/login/</a>.
-Sign in using the same Google Account you used above.
-</p>
-<h2 id="cla">Contributor License Agreement</h2>
+<h3 id="cla">Step 1: Contributor License Agreement</h3>
-<h3 id="which_cla">Which CLA</h3>
<p>
Before sending your first change to the Go project
you must have completed one of the following two CLAs.
@@ -126,42 +147,77 @@ contributor license agreement</a>.<br>
</ul>
<p>
-<i>If the copyright holder for your contribution has already completed the
+You can check your currently signed agreements and sign new ones at
+the <a href="https://cla.developers.google.com/clas?pli=1&amp;authuser=1">Google Developers
+Contributor License Agreements</a> website.
+If the copyright holder for your contribution has already completed the
agreement in connection with another Google open source project,
-it does not need to be completed again.</i>
+it does not need to be completed again.
+</p>
+
+<p>
+If the copyright holder for the code you are submitting changes&mdash;for example,
+if you start contributing code on behalf of a new company&mdash;please send mail
+to the <a href="mailto:golang-dev@googlegroups.com"><code>golang-dev</code>
+mailing list</a>.
+This will let us know the situation so we can make sure an appropriate agreement is
+completed and update the <code>AUTHORS</code> file.
</p>
-<h3 id="signing_cla">Completing the CLA</h3>
+
+<h3 id="config_git_auth">Step 2: Configure git authentication</h3>
<p>
-You can see your currently signed agreements and sign new ones through the Gerrit
-interface.
-To do this, <a href="https://go-review.googlesource.com/login/">Log into Gerrit</a>,
-then visit the <a href="https://go-review.googlesource.com/settings/agreements">Agreements</a>
-page.
-If you do not have a signed agreement listed there, you can create one
-by clicking "New Contributor Agreement" and following the steps.
+Go development happens on
+<a href="https://go.googlesource.com">go.googlesource.com</a>,
+a Git server hosted by Google.
+Authentication on the web server is made through your Google account, but
+you also need to configure <code>git</code> on your computer to access it.
+Follow this steps:
</p>
+<ol>
+<li>
+Visit <a href="https://go.googlesource.com">go.googlesource.com</a>
+and click on "Generate Password" in the page's top right menu bar.
+You will be redirected to accounts.google.com to sign in.
+</li>
+<li>
+After signing in, you will be taken to a page with the title "Configure Git".
+This page contains a personalized script that when run locally will configure Git
+to hold your unique authentication key.
+This key is paired with one that is generated and stored on the server,
+analogous to how SSH keys work.
+</li>
+<li>
+Copy and run this script locally in your command line terminal to store your
+secret authentication token in a <code>.gitcookies</code> file.
+If you are using a Windows computer and running <code>cmd</code>,
+you should instead follow the instructions in the yellow box to run the command;
+otherwise run the regular script.
+</li>
+</ol>
+
+<h3 id="auth">Step 3: Create a Gerrit account </h3>
+
<p>
-If the copyright holder for the code you are submitting changes &mdash; for example,
-if you start contributing code on behalf of a new company &mdash; please send email
-to golang-dev and let us know, so that we can make sure an appropriate agreement is
-completed and update the <code>AUTHORS</code> file.
+Gerrit is an open-source tool used by Go maintainers to discuss and review
+code submissions.
+</p>
+
+<p>
+To register your account, visit <a href="https://go-review.googlesource.com/login/">
+go-review.googlesource.com/login/</a> and sign in once using the same Google Account you used above.
</p>
-<span id="Code_review"></span>
-<h1 id="prepare_dev_env">Preparing a Development Environment for Contributing</h1>
+<h3 id="git-codereview_install">Step 4: Install the git-codereview command</h3>
-<h2 id="git-codereview">Setting up Git for submission to Gerrit</h2>
<p>
Changes to Go must be reviewed before they are accepted, no matter who makes the change.
-A custom git command called <code>git-codereview</code>, discussed below,
-helps manage the code review process through a Google-hosted
-<a href="https://go-review.googlesource.com/">instance</a> of Gerrit.
+A custom <code>git</code> command called <code>git-codereview</code>
+simplifies sending changes to Gerrit.
</p>
-<h3 id="git-codereview_install">Install the git-codereview command</h3>
<p>
Install the <code>git-codereview</code> command by running,
</p>
@@ -172,7 +228,8 @@ $ go get -u golang.org/x/review/git-codereview
<p>
Make sure <code>git-codereview</code> is installed in your shell path, so that the
-<code>git</code> command can find it. Check that
+<code>git</code> command can find it.
+Check that
</p>
<pre>
@@ -185,439 +242,686 @@ prints help text, not an error.
<p>
On Windows, when using git-bash you must make sure that
-<code>git-codereview.exe</code> is in your git exec-path.
+<code>git-codereview.exe</code> is in your <code>git</code> exec-path.
Run <code>git --exec-path</code> to discover the right location then create a
-symbolic link or simply copy the executable from $GOPATH/bin to this directory.
+symbolic link or just copy the executable from $GOPATH/bin to this directory.
+</p>
+
+
+<h2 id="before_contributing">Before contributing code</h2>
+
+<p>
+The project welcomes submissions but to make sure things are well
+coordinated we ask that everyone to discuss any significant changes to the
+Go repositories before starting work.
+Best practice is to connect your work to the issue tracker,
+either by <a href="https://golang.org/issue/new">filing a new issue</a>
+or by claiming an <a href="https://golang.org/issues">existing issue</a>.
</p>
+<h3>Check the issue tracker</h3>
+
<p>
-<b>Note to Git aficionados:</b>
-The <code>git-codereview</code> command is not required to
-upload and manage Gerrit code reviews.
-For those who prefer plain Git, the text below gives the Git equivalent of
-each git-codereview command.
+Whether you already know what contribution to make, or you are searching for
+an idea, the <a href="https://github.com/golang/go/issues">issue tracker</a> is
+always the first place to go.
+Issues are triaged to categorize them and manage the workflow.
</p>
<p>
-If you do use plain Git, note that you still need the commit hooks that the
-git-codereview command configures; those hooks add a Gerrit
-<code>Change-Id</code> line to the commit message and check that all Go source
-files have been formatted with gofmt.
-Even if you intend to use plain Git for
-daily work, install the hooks in a new Git checkout by running
-<code>git-codereview</code> <code>hooks</code>.
+Most issues will be marked with one of the following workflow labels:
</p>
-<h3 id="git-config">Set up git aliases</h3>
+<ul>
+ <li>
+ <b>NeedsInvestigation</b>: The issue is not fully understood
+ and requires analysis to understand the root cause.
+ </li>
+ <li>
+ <b>NeedsDecision</b>: the issue is relatively well understood, but the
+ Go team hasn't yet decided the best way to address it.
+ It would be better to wait for a decision before writing code.
+ If you are interested on working on an issue in this state,
+ feel free to "ping" maintainers in the issue's comments
+ if some time has passed without a decision.
+ </li>
+ <li>
+ <b>NeedsFix</b>: the issue is fully understood and code can be written
+ to fix it.
+ </li>
+</ul>
+
+<h3 id="design">Open an issue for any new problem</h3>
<p>
-The <code>git-codereview</code> command can be run directly from the shell
-by typing, for instance,
+Excluding very trivial changes, all contributions should be connected
+to an existing issue.
+Feel free to open one and discuss your plans.
+This process gives everyone a chance to validate the design,
+helps prevent duplication of effort,
+and ensures that the idea fits inside the goals for the language and tools.
+It also checks that the design is sound before code is written;
+the code review tool is not the place for high-level discussions.
</p>
-<pre>
-$ git codereview sync
-</pre>
+<p>
+When planning work, please note that the Go project follows a <a
+href="https://golang.org/wiki/Go-Release-Cycle">six-month development cycle</a>.
+The latter half of each cycle is a three-month feature freeze during
+which only bug fixes and documentation updates are accepted.
+New contributions can be
+sent during a feature freeze but will not be accepted until the freeze is over.
+</p>
<p>
-but it is more convenient to set up aliases for <code>git-codereview</code>'s own
-subcommands, so that the above becomes,
+Changes in general other than bug and documentation fixes
+must go through the
+<a href="https://golang.org/s/proposal-process">change proposal process</a>
+before they can be accepted.
</p>
-<pre>
-$ git sync
-</pre>
+<p>
+Sensitive security-related issues (only!) should be reported to <a href="mailto:security@golang.org">security@golang.org</a>.
+</p>
+
+<h2 id="sending_a_change_github">Sending a change via GitHub</h2>
<p>
-The <code>git-codereview</code> subcommands have been chosen to be distinct from
-Git's own, so it's safe to do so.
+First-time contributors that are already familiar with the
+<a href="https://guides.github.com/introduction/flow/">GitHub flow</a>
+are encouraged to use the same process for Go contributions.
+Even though Go
+maintainers use Gerrit for code review, a bot called Gopherbot has been created to sync
+GitHub pull requests to Gerrit.
+</p>
+
+<p>
+Open a pull request as you normally would.
+Gopherbot will automatically
+sync the code and post a link to Gerrit.
+When somebody comments on the
+change, it will be posted in the pull request, so you will also get a notification.
</p>
<p>
-The aliases are optional, but in the rest of this document we will assume
-they are installed.
-To install them, copy this text into your Git configuration file
-(usually <code>.gitconfig</code> in your home directory):
+Some things to keep in mind:
</p>
+<ul>
+<li>
+To update the pull request with new code, just push it to the branch; you can either
+add more commits, or rebase and force-push (both styles are accepted).
+</li>
+<li>
+If the request is accepted, all commits will be squashed, and the final
+commit description will be composed by concatenating the pull request's
+title and description.
+The individual commits' descriptions will be discarded.
+See <a href="#commit_messages">Writing good commit messages</a> for some
+suggestions.
+</li>
+<li>
+Gopherbot is unable to sync line-by-line codereview into GitHub: only the
+contents of the overall comment on the request will be synced.
+Remember you can always visit Gerrit to see the fine-grained review.
+</li>
+</ul>
+
+<h2 id="sending_a_change_gerrit">Sending a change via Gerrit</h2>
+
+<p>
+It is not possible to fully sync Gerrit and GitHub, at least at the moment,
+so we recommend learning Gerrit.
+It's different but powerful and familiarity
+with help you understand the flow.
+</p>
+
+<h3>Overview</h3>
+
+<p>
+This is an overview of the overall process:
+</p>
+
+<ul>
+<li>
+<b>Step 1:</b> Clone the Go source code from GitHub or go.googlesource.com
+and make sure it's stable by compiling and testing it once:
<pre>
-[alias]
- change = codereview change
- gofmt = codereview gofmt
- mail = codereview mail
- pending = codereview pending
- submit = codereview submit
- sync = codereview sync
+$ git clone https://github.com/golang/go # or https://go.googlesource.com/go
+$ cd go/src
+$ ./all.bash # compile and test
</pre>
+</li>
-<span id="help"></span>
-<h3 id="understanding_git-codereview">Understanding the git-codereview command</h3>
+<li>
+<b>Step 2:</b> Prepare changes in a new branch, created from the master branch.
+To commit the changes, use <code>git</code> <code>codereview</code> <code>change</code>; that
+will create or amend a single commit in the branch.
+<pre>
+$ git checkout -b mybranch
+$ [edit files...]
+$ git add [files...]
+$ git codereview change # create commit in the branch
+$ [edit again...]
+$ git add [files...]
+$ git codereview change # amend the existing commit with new changes
+$ [etc.]
+</pre>
+</li>
-<p>After installing the <code>git-codereview</code> command, you can run</p>
+<li>
+<b>Step 3:</b> Test your changes, re-running <code>all.bash</code>.
+<pre>
+$ ./all.bash # recompile and test
+</pre>
+</li>
+<li>
+<b>Step 4:</b> Send the changes for review to Gerrit using <code>git</code>
+<code>codereview</code> <code>mail</code>(which doesn't use e-mail, despite the name).
<pre>
-$ git codereview help
+$ git codereview mail # send changes to Gerrit
+</pre>
+</li>
+
+<li>
+<b>Step 5:</b> After a review, apply changes to the same single commit
+and mail them to Gerrit again:
+<pre>
+$ [edit files...]
+$ git add [files...]
+$ git codereview change # update same commit
+$ git codereview mail # send to Gerrit again
</pre>
+</li>
+</ul>
<p>
-to learn more about its commands.
-You can also read the <a href="https://godoc.org/golang.org/x/review/git-codereview">command documentation</a>.
+The rest of this section describes these steps in more detail.
</p>
-<h1 id="making_a_contribution">Making a Contribution</h1>
-
-<h2 id="Design">Discuss your design</h2>
+<h3 id="checkout_go">Step 1: Clone the Go source code</h3>
<p>
-The project welcomes submissions but please let everyone know what
-you're working on if you want to change or add to the Go repositories.
+In addition to a recent Go installation, you need to have a local copy of the source
+checked out from the correct repository.
+You can check out the Go source repo onto your local file system anywhere
+you want as long as it's outside your <code>GOPATH</code>.
+Either clone from
+<code>go.googlesource.com</code> or from GitHub:
</p>
+<pre>
+$ git clone https://github.com/golang/go # or https://go.googlesource.com/go
+$ cd go
+</pre>
+
+<h3 id="make_branch">Step 2: Prepare changes in a new branch</h3>
+
<p>
-Before undertaking to write something new for the Go project,
-please <a href="https://golang.org/issue/new">file an issue</a>
-(or claim an <a href="https://golang.org/issues">existing issue</a>).
-Significant changes must go through the
-<a href="https://golang.org/s/proposal-process">change proposal process</a>
-before they can be accepted.
+Each Go change must be made in a separate branch, created from the master branch.
+You can use
+the normal <code>git</code> commands to create a branch and add changes to the
+staging area:
</p>
+<pre>
+$ git checkout -b mybranch
+$ [edit files...]
+$ git add [files...]
+</pre>
+
<p>
-This process gives everyone a chance to validate the design,
-helps prevent duplication of effort,
-and ensures that the idea fits inside the goals for the language and tools.
-It also checks that the design is sound before code is written;
-the code review tool is not the place for high-level discussions.
+To commit changes, instead of <code>git commit</code>, use <code>git codereview change</code>.
</p>
+<pre>
+$ git codereview change
+(open $EDITOR)
+</pre>
+
<p>
-When planning work, please note that the Go project follows a <a
-href="https://golang.org/wiki/Go-Release-Cycle">six-month development cycle</a>.
-The latter half of each cycle is a three-month feature freeze during
-which only bug fixes and doc updates are accepted. New contributions can be
-sent during a feature freeze but will not be accepted until the freeze thaws.
+You can edit the commit description in your favorite editor as usual.
+The <code>git</code> <code>codereview</code> <code>change</code> command
+will automatically add a unique Change-Id line near the bottom.
+That line is used by Gerrit to match successive uploads of the same change.
+Do not edit or delete it.
+A Change-Id looks like this:
</p>
-<h3 id="scratch">Not sure what change to make?</h3>
+<pre>
+Change-Id: I2fbdbffb3aab626c4b6f56348861b7909e3e8990
+</pre>
<p>
-If you want to become familiar with Gerrit and the contribution process,
-but aren't sure what you'd like to contribute just yet, you can use the <a
-href="https://go.googlesource.com/scratch">scratch repository</a> to practice
-making a change.
+The tool also checks that you've
+run <code>go</code> <code>fmt</code> over the source code, and that
+the commit message follows the <a href="#commit_messages">suggested format</a>.
</p>
-<h2 id="making_a_change">Making a change</h2>
+<p>
+If you need to edit the files again, you can stage the new changes and
+re-run <code>git</code> <code>codereview</code> <code>change</code>: each subsequent
+run will amend the existing commit while preserving the Change-Id.
+</p>
-<h3 id="checkout_go">Getting Go Source</h3>
<p>
-First you need to have a local copy of the source checked out from the correct
-repository.
-As Go builds Go you will also likely need to have a working version
-of Go installed (some documentation changes may not need this).
-This should be a recent version of Go and can be obtained via any package or
-binary distribution or you can build it from source.
+Make sure that you always keep a single commit in each branch.
+If you add more
+commits by mistake, you can use <code>git</code> <code>rebase</code> to
+<a href="https://stackoverflow.com/questions/31668794/squash-all-your-commits-in-one-before-a-pull-request-in-github">squash them together</a>
+into a single one.
</p>
+
+<h3 id="testing">Step 3: Test your changes</h3>
+
<p>
-You should checkout the Go source repo anywhere you want as long as it's
-outside of your $GOPATH.
-Go to a directory where you want the source to appear and run the following
-command in a terminal.
+You've <a href="code.html">written and tested your code</a>, but
+before sending code out for review, run <i>all the tests for the whole
+tree</i> to make sure the changes don't break other packages or programs:
</p>
<pre>
-$ git clone https://go.googlesource.com/go
-$ cd go
+$ cd go/src
+$ ./all.bash
</pre>
-<h3 id="master">Contributing to the main Go tree</h3>
+<p>
+(To build under Windows use <code>all.bat</code>; this also requires
+setting the environment variable <code>GOROOT_BOOTSTRAP</code> to the
+directory holding the Go tree for the bootstrap compiler.)
+</p>
<p>
-Most Go installations use a release branch, but new changes should
-only be made based on the master branch. <br>
-(They may be applied later to a release branch as part of the release process,
-but most contributors won't do this themselves.)
-Before making a change, make sure you start on the master branch:
+After running for a while and printing a lot of testing output, the command should finish
+by printing,
</p>
<pre>
-$ git checkout master
-$ git sync
+ALL TESTS PASSED
</pre>
<p>
-(In Git terms, <code>git</code> <code>sync</code> runs
-<code>git</code> <code>pull</code> <code>-r</code>.)
+You can use <code>make.bash</code> instead of <code>all.bash</code>
+to just build the compiler and standard packages without running the test suite.
+Once the <code>go</code> tool is built, it will be installed as <code>bin/go</code>
+under the directory in which you cloned the Go repository, and you can
+run it directly from there.
+See also
+the section on how to <a href="#quick_test">test your changes quickly</a>.
</p>
-<h3 id="subrepos">Contributing to subrepositories (golang.org/x/...)</h3>
+<h3 id="mail">Step 4: Send changes for review</h3>
<p>
-If you are contributing a change to a subrepository, obtain the
-Go package using <code>go get</code>. For example, to contribute
-to <code>golang.org/x/oauth2</code>, check out the code by running:
+Once the change is ready and tested over the whole tree, send it for review.
+This is done with the <code>mail</code> sub-command which, despite its name, doesn't
+directly mail anything; it just sends the change to Gerrit:
</p>
<pre>
-$ go get -d golang.org/x/oauth2/...
+$ git codereview mail
</pre>
<p>
-Then, change your directory to the package's source directory
-(<code>$GOPATH/src/golang.org/x/oauth2</code>).
+Gerrit assigns your change a number and URL, which <code>git</code> <code>codereview</code> <code>mail</code> will print, something like:
</p>
-<h3 id="change">Make your changes</h3>
+<pre>
+remote: New Changes:
+remote: https://go-review.googlesource.com/99999 math: improved Sin, Cos and Tan precision for very large arguments
+</pre>
+
+<p>
+If you get an error instead, check the
+<a href="#troubleshooting_mail">Troubleshooting mail errors</a> section.
+</p>
<p>
-The entire checked-out tree is editable.
-Make your changes as you see fit ensuring that you create appropriate
-tests along with your changes. Test your changes as you go.
+If your change relates to an open GitHub issue and you have followed the <a href="#commit_messages">
+suggested commit message format</a>, the issue will be updated in a few minutes by a bot,
+linking your Gerrit change to it in the comments.
</p>
-<h3 id="copyright">Copyright</h3>
+
+<h3 id="revise">Step 5: Revise changes after a review</h3>
<p>
-Files in the Go repository don't list author names, both to avoid clutter
-and to avoid having to keep the lists up to date.
-Instead, your name will appear in the
-<a href="https://golang.org/change">change log</a> and in the <a
-href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file and perhaps the <a
-href="/AUTHORS"><code>AUTHORS</code></a> file.
-These files are automatically generated from the commit logs periodically.
-The <a href="/AUTHORS"><code>AUTHORS</code></a> file defines who &ldquo;The Go
-Authors&rdquo;&mdash;the copyright holders&mdash;are.
+Go maintainers will review your code on Gerrit, and you will get notifications via e-mail.
+You can see the review on Gerrit and comment on them there.
+You can also reply
+<a href="https://gerrit-review.googlesource.com/Documentation/intro-user.html#reply-by-email">using e-mail</a>
+if you prefer.
</p>
-<p>New files that you contribute should use the standard copyright header:</p>
+<p>
+If you need to revise your change after the review, edit the files in correct branch,
+add them to the Git staging area, and then amend the commit with
+<code>git</code> <code>codereview</code> <code>change</code>:
+</p>
<pre>
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
+$ git codereview change # amend current commit
+(open $EDITOR)
+$ git codereview mail # send new changes to Gerrit
</pre>
<p>
-Files in the repository are copyright the year they are added.
-Do not update the copyright year on files that you change.
+If you don't need to change the commit description, just save and exit from the editor.
+Remember not to touch the special Change-Id line.
</p>
-<h3 id="commit_changes">Commit your changes</h3>
-
<p>
-Once you have edited files, you must tell Git that they have been modified.
-You must also tell Git about any files that are added, removed, or renamed files.
-These operations are done with the usual Git commands,
-<code>git</code> <code>add</code>,
-<code>git</code> <code>rm</code>,
-and
-<code>git</code> <code>mv</code>.
+Again, make sure that you always keep a single commit in each branch.
+If you add more
+commits by mistake, you can use <code>git rebase</code> to
+<a href="https://stackoverflow.com/questions/31668794/squash-all-your-commits-in-one-before-a-pull-request-in-github">squash them together</a>
+into a single one.
</p>
+<h2 id="commit_messages">Good commit messages</h2>
+
<p>
-Once you have the changes queued up, you will want to commit them.
-In the Go contribution workflow this is done with a <code>git</code>
-<code>change</code> command, which creates a local branch and commits the changes
-directly to that local branch.
+Commit messages in Go follow a specific set of conventions,
+which we discuss in this section.
</p>
<p>
-The workflow described here assumes a single change per branch.
-It is also possible to prepare a sequence of (usually related) changes in a single branch.
-See the <a href="https://golang.org/x/review/git-codereview">git-codereview documentation</a> for details.
+Here is an example of a good one:
</p>
<pre>
-$ git change <i>&lt;branch&gt;</i>
+math: improve Sin, Cos and Tan precision for very large arguments
+
+The existing implementation has poor numerical properties for
+large arguments, so use the McGillicutty algorithm to improve
+accuracy above 1e10.
+
+The algorithm is described at http://wikipedia.org/wiki/McGillicutty_Algorithm
+
+Fixes #159
</pre>
+<h3>First line</h3>
+
<p>
-The name <i>&lt;branch&gt;</i> is an arbitrary one you choose to identify the
-local branch containing your changes and will not be used elsewhere.
-This is an offline operation and nothing will be sent to the server yet.
+The first line of the change description is conventionally a short one-line
+summary of the change, prefixed by the primary affected package.
</p>
<p>
-(In Git terms, <code>git</code> <code>change</code> <code>&lt;branch&gt;</code>
-runs <code>git</code> <code>checkout</code> <code>-b</code> <code>branch</code>,
-then <code>git</code> <code>branch</code> <code>--set-upstream-to</code> <code>origin/master</code>,
-then <code>git</code> <code>commit</code>.)
+A rule of thumb is that it should be written so to complete the sentence
+"This change modifies Go to _____."
+That means it does not start with a capital letter, is not a complete sentence,
+and actually summarizes the result of the change.
</p>
<p>
-As the <code>git</code> <code>commit</code> is the final step, Git will open an
-editor to ask for a commit message. (It uses the editor named by
-the <code>$EDITOR</code> environment variable,
-<code>vi</code> by default.)
-
-The file will look like:
+Follow the first line by a blank line.
</p>
-<pre>
-
-# Please enter the commit message for your changes. Lines starting
-# with '#' will be ignored, and an empty message aborts the commit.
-# On branch foo
-# Changes not staged for commit:
-# modified: editedfile.go
-#
-</pre>
+<h3>Main content</h3>
<p>
-At the beginning of this file is a blank line; replace it
-with a thorough description of your change.
-The first line of the change description is conventionally a one-line
-summary of the change, prefixed by the primary affected package,
-and is used as the subject for code review email.
-It should complete the sentence "This change modifies Go to _____."
The rest of the description elaborates and should provide context for the
change and explain what it does.
Write in complete sentences with correct punctuation, just like
for your comments in Go.
-If there is a helpful reference, mention it here.
-If you've fixed an issue, reference it by number with a # before it.
+Don't use HTML, Markdown, or any other markup language.
</p>
<p>
-After editing, the template might now read:
+Add any relevant information, such as benchmark data if the change
+afects performance.
+The <a href="https://godoc.org/golang.org/x/tools/cmd/benchcmp">benchcmp</a>
+tool is conventionally used to format
+benchmark data for change descriptions.
</p>
-<pre>
-math: improve Sin, Cos and Tan precision for very large arguments
+<h3>Referencing issues</h3>
-The existing implementation has poor numerical properties for
-large arguments, so use the McGillicutty algorithm to improve
-accuracy above 1e10.
+<p>
+The special notation "Fixes #12345" associates the change with issue 12345 in the
+<a href="https://golang.org/issue/12345">Go issue tracker</a>.
+When this change is eventually applied, the issue
+tracker will automatically mark the issue as fixed.
+</p>
-The algorithm is described at http://wikipedia.org/wiki/McGillicutty_Algorithm
+<p>
+If the change is a partial step towards the resolution of the issue,
+uses the notation "Updates #12345".
+This will leave a comment in the issue
+linking back to the change in Gerrit, but it will not close the issue
+when the change is applied.
+</p>
-Fixes #159
+<p>
+If you are sending a change against a subrepository, you must use
+the fully-qualified syntax supported by GitHub to make sure the change is
+linked to the issue in the main repository, not the subrepository.
+All issues are tracked in the main repository's issue tracker.
+The correct form is "Fixes golang/go#159".
+</p>
-# Please enter the commit message for your changes. Lines starting
-# with '#' will be ignored, and an empty message aborts the commit.
-# On branch foo
-# Changes not staged for commit:
-# modified: editedfile.go
-#
-</pre>
+
+<h2 id="review">The review process</h2>
<p>
-The commented section of the file lists all the modified files in your client.
-It is best to keep unrelated changes in different commits,
-so if you see a file listed that should not be included, abort
-the command and move that file to a different branch.
+This section explains the review process in detail and how to approach
+reviews after a change has been mailed.
</p>
+
+<h3 id="mistakes">Common beginner mistakes</h3>
+
<p>
-The special notation "Fixes #159" associates the change with issue 159 in the
-<a href="https://golang.org/issue/159">Go issue tracker</a>.
-When this change is eventually applied, the issue
-tracker will automatically mark the issue as fixed.
-(There are several such conventions, described in detail in the
-<a href="https://help.github.com/articles/closing-issues-via-commit-messages/">GitHub Issue Tracker documentation</a>.)
+When a change is sent to Gerrit, it is usually triaged within a few days.
+A maintainer will have a look and provide some initial review that for first-time
+contributors usually focuses on basic cosmetics and common mistakes.
+These include things like:
</p>
+<ul>
+<li>
+Commit message not following the <a href="#commit_messages">suggested
+format</a>.
+</li>
+
+<li>
+The lack of a linked GitHub issue.
+The vast majority of changes
+require a linked issue that describes the bug or the feature that the change
+fixes or implements, and consensus should have been reached on the tracker
+before proceeding with it.
+Gerrit reviews do not discuss the merit of the change,
+just its implementation.
+<br>
+Only trivial or cosmetic changes will be accepted without an associated issue.
+</li>
+
+<li>
+Change sent during the freeze phase of the development cycle, when the tree
+is closed for general changes.
+In this case,
+a maintainer might review the code with a line such as <code>R=go1.12</code>,
+which means that it will be reviewed later when the tree opens for a new
+development window.
+You can add <code>R=go1.XX</code> as a comment yourself
+if you know that it's not the correct time frame for the change.
+</li>
+</ul>
+
+<h3 id="trybots">Trybots</h3>
+
<p>
-Once you have finished writing the commit message,
-save the file and exit the editor.
+After an initial reading of your change, maintainers will trigger trybots,
+a cluster of servers that will run the full test suite on several different
+architectures.
+Most trybots complete in a few minutes, at which point a link will
+be posted in Gerrit where you can see the results.
</p>
<p>
-You must have the $EDITOR environment variable set properly and working properly (exiting cleanly)
-for this operation to succeed.
-If you run into any issues at this step, it's likely your editor isn't exiting cleanly.
-Try setting a different editor in your $EDITOR environment variable.
+If the trybot run fails, follow the link and check the full logs of the
+platforms on which the tests failed.
+Try to understand what broke, update your patch to fix it, and upload again.
+Maintainers will trigger a new trybot run to see
+if the problem was fixed.
</p>
<p>
-If you wish to do more editing, re-stage your changes using
-<code>git</code> <code>add</code>, and then run
+Sometimes, the tree can be broken on some platforms for a few hours; if
+the failure reported by the trybot doesn't seem related to your patch, go to the
+<a href="https://build.golang.org">Build Dashboard</a> and check if the same
+failure appears in other recent commits on the same platform.
+In this case,
+feel free to write a comment in Gerrit to mention that the failure is
+unrelated to your change, to help maintainers understand the situation.
</p>
-<pre>
-$ git change
-</pre>
+<h3 id="reviews">Reviews</h3>
<p>
-to update the change description and incorporate the staged changes.
-The change description contains a <code>Change-Id</code> line near the bottom,
-added by a Git commit hook during the initial
-<code>git</code> <code>change</code>.
-That line is used by Gerrit to match successive uploads of the same change.
-Do not edit or delete it.
+The Go community values very thorough reviews.
+Think of each review comment like a ticket: you are expected to somehow "close" it
+by acting on it, either by implementing the suggestion or convincing the
+reviewer otherwise.
+</p>
+
+<p>
+After you update the change, go through the review comments and make sure
+to reply to every one.
+You can click the "Done" button to reply
+indicating that you've implemented the reviewer's suggestion; otherwise,
+click on "Reply" and explain why you have not, or what you have done instead.
</p>
<p>
-(In Git terms, <code>git</code> <code>change</code> with no branch name
-runs <code>git</code> <code>commit</code> <code>--amend</code>.)
+It is perfectly normal for changes to go through several round of reviews,
+with one or more reviewers making new comments every time
+and then waiting for an updated change before reviewing again.
+This cycle happens even for experienced contributors, so
+don't be discouraged by it.
</p>
-<h3 id="Testing">Testing</h3>
+<h3 id="votes">Voting conventions</h3>
<p>
-You've <a href="code.html">written and tested your code</a>, but
-before sending code out for review, run all the tests for the whole
-tree to make sure the changes don't break other packages or programs:
+As they near a decision, reviewers will make a "vote" on your change.
+The Gerrit voting system involves an integer in the range -2 to +2:
</p>
-<pre>
-$ cd go/src
-$ ./all.bash
-</pre>
+<ul>
+ <li>
+ <b>+2</b> The change is approved for being merged.
+ Only Go maintainers can cast a +2 vote.
+ </li>
+ <li>
+ <b>+1</b> The change looks good, but either the reviewer is requesting
+ minor changes before approving it, or they are not a maintainer and cannot
+ approve it, but would like to encourage an approval.
+ </li>
+ <li>
+ <b>-1</b> The change is not good the way it is but might be fixable.
+ A -1 vote will always have a comment explaining why the change is unacceptable.
+ </li>
+ <li>
+ <b>-2</b> The change is blocked by a maintainer and cannot be approved.
+ Again, there will be a comment explaining the decision.
+ </li>
+</ul>
+
+<h3 id="submit">Submitting an approved change</h3>
<p>
-(To build under Windows use <code>all.bat</code>.)
+After the code has been +2'ed, an approver will
+apply it to the master branch using the Gerrit user interface.
+This is called "submitting the change".
</p>
<p>
-After running for a while, the command should print
+The two steps (approving and submitting) are separate because in some cases maintainers
+may want to approve it but not to submit it right away (for instance,
+the tree could be temporarily frozen).
</p>
-<pre>
-"ALL TESTS PASSED".
-</pre>
+<p>
+Submitting a change checks it into the repository.
+The change description will include a link to the code review,
+which will be updated with a link to the change
+in the repository.
+Since the method used to integrate the changes is Git's "Cherry Pick",
+the commit hashes in the repository will be changed by
+the submit operation.
+</p>
+
+<p>
+If your change has been approved for a few days without being
+submitted, feel free to write a comment in Gerrit requesting
+submission.
+</p>
-<h3 id="mail">Send the change for review</h3>
+
+<h3 id="more_information">More information</h3>
<p>
-Once the change is ready, send it for review.
-This is similar to a <code>git push</code> in a GitHub style workflow.
-This is done via the mail alias setup earlier which despite its name, doesn't
-directly mail anything, it simply sends the change to Gerrit via git push.
+In addition to the information here, the Go community maintains a <a
+href="https://golang.org/wiki/CodeReview">CodeReview</a> wiki page.
+Feel free to contribute to this page as you learn more about the review process.
</p>
-<pre>
-$ git mail
-</pre>
+
+
+<h2 id="advanced_topics">Miscellaneous topics</h2>
<p>
-(In Git terms, <code>git</code> <code>mail</code> pushes the local committed
-changes to Gerrit using <code>git</code> <code>push</code> <code>origin</code>
-<code>HEAD:refs/for/master</code>.)
+This section collects a number of other comments that are
+outside the issue/edit/code review/submit process itself.
</p>
+
+<h3 id="copyright">Copyright headers</h3>
+
<p>
-If your change relates to an open issue, please add a comment to the issue
-announcing your proposed fix, including a link to your change.
+Files in the Go repository don't list author names, both to avoid clutter
+and to avoid having to keep the lists up to date.
+Instead, your name will appear in the
+<a href="https://golang.org/change">change log</a> and in the <a
+href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file and perhaps the <a
+href="/AUTHORS"><code>AUTHORS</code></a> file.
+These files are automatically generated from the commit logs periodically.
+The <a href="/AUTHORS"><code>AUTHORS</code></a> file defines who &ldquo;The Go
+Authors&rdquo;&mdash;the copyright holders&mdash;are.
</p>
<p>
-The code review server assigns your change an issue number and URL,
-which <code>git</code> <code>mail</code> will print, something like:
+New files that you contribute should use the standard copyright header:
</p>
<pre>
-remote: New Changes:
-remote: https://go-review.googlesource.com/99999 math: improved Sin, Cos and Tan precision for very large arguments
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
</pre>
-<h3>Troubleshooting</h3>
+<p>
+(Use the current year if you're reading this in 2019 or beyond.)
+Files in the repository are copyrighted the year they are added.
+Do not update the copyright year on files that you change.
+</p>
+
+
+
+
+<h3 id="troubleshooting_mail">Troubleshooting mail errors</h3>
<p>
-The most common way that the <code>git mail</code> command fails is because the
-email address used has not gone through the setup above.
+The most common way that the <code>git</code> <code>codereview</code> <code>mail</code>
+command fails is because the e-mail address in the commit does not match the one
+that you used during <a href="#google_account">the registration process</a>.
+
<br>
If you see something like...
</p>
@@ -631,13 +935,9 @@ remote: ERROR: does not match your user account.
</pre>
<p>
-You need to either add the email address listed to the CLA or set this repo to use
-another email address already approved.
-</p>
-
-<p>
-First let's change the email address for this repo so this doesn't happen again.
-You can change your email address for this repo with the following command:
+you need to configure Git for this repository to use the
+e-mail address that you registered with.
+To change the e-mail address for this doesn't happen again, run:
</p>
<pre>
@@ -645,8 +945,7 @@ $ git config user.email email@address.com
</pre>
<p>
-Then change the previous commit to use this alternative email address.
-You can do that with:
+Then change the commit to use this alternative e-mail address with this command:
</p>
<pre>
@@ -654,244 +953,239 @@ $ git commit --amend --author="Author Name &lt;email@address.com&gt;"
</pre>
<p>
-Finally try to resend with:
+Then retry by running:
</p>
<pre>
-$ git mail
+$ git codereview mail
</pre>
-<h3 id="cc">Specifying a reviewer / CCing others</h3>
-<p>
-Unless explicitly told otherwise, such as in the discussion leading
-up to sending in the change, it's better not to specify a reviewer.
-All changes are automatically CC'ed to the
-<a href="https://groups.google.com/group/golang-codereviews">golang-codereviews@googlegroups.com</a>
-mailing list. If this is your first ever change, there may be a moderation
-delay before it appears on the mailing list, to prevent spam.
-</p>
+<h3 id="quick_test">Quickly testing your changes</h3>
<p>
-You can specify a reviewer or CC interested parties
-using the <code>-r</code> or <code>-cc</code> options.
-Both accept a comma-separated list of email addresses:
+Running <code>all.bash</code> for every single change to the code tree
+is burdensome.
+Even though it is strongly suggested to run it before
+sending a change, during the normal development cycle you may want
+to compile and test only the package you are developing.
</p>
+<ul>
+<li>
+In general, you can run <code>make.bash</code> instead of <code>all.bash</code>
+to only rebuild the Go tool chain without running the whole test suite.
+Or you
+can run <code>run.bash</code> to only run the whole test suite without rebuilding
+the tool chain.
+You can think of <code>all.bash</code> as <code>make.bash</code>
+followed by <code>run.bash</code>.
+</li>
+
+<li>
+In this section, we'll call the directory into which you cloned the Go repository <code>$GODIR</code>.
+The <code>go</code> tool built by <code>$GODIR/make.bash</code>will be installed
+in <code>$GODIR/bin/go</code>and you
+can invoke it to test your code.
+For instance, if you
+have modified the compiler and you want to test how it affects the
+test suite of your own project, just run <code>go</code> <code>test</code>
+using it:
+
<pre>
-$ git mail -r joe@golang.org -cc mabel@example.com,math-nuts@swtch.com
+$ cd &lt;MYPROJECTDIR&gt;
+$ $GODIR/bin/go test
</pre>
+</li>
-<h2 id="review">Going through the review process</h2>
-
-<p>
-Running <code>git</code> <code>mail</code> will send an email to you and the
-reviewers asking them to visit the issue's URL and make comments on the change.
-When done, the reviewer adds comments through the Gerrit user interface
-and clicks "Reply" to send comments back.
-You will receive a mail notification when this happens.
-You may reply through the web interface or
-<a href="https://gerrit-review.googlesource.com/Documentation/intro-user.html#reply-by-email">via email</a>.
-</p>
+<li>
+If you're changing the standard library, you probably don't need to rebuild
+the compiler: you can just run the tests for the package you've changed.
+You can do that either with the Go version you normally use, or
+with the Go compiler built from your clone (which is
+sometimes required because the standard library code you're modifying
+might require a newer version than the stable one you have installed).
-<h3 id="revise">Revise and resend</h3>
+<pre>
+$ cd $GODIR/src/hash/sha1
+$ [make changes...]
+$ $GODIR/bin/go test .
+</pre>
+</li>
-<p>
-The Go contribution workflow is optimized for iterative revisions based on
-feedback.
-It is rare that an initial contribution will be ready to be applied as is.
-As you revise your contribution and resend Gerrit will retain a history of
-all the changes and comments made in the single URL.
-</p>
+<li>
+If you're modifying the compiler itself, you can just recompile
+the <code>compile</code> tool (which is the internal binary invoked
+by <code>go</code> <code>build</code> to compile each single package).
+After that, you will want to test it by compiling or running something.
-<p>
-You may respond to review comments through the web interface or
-<a href="https://gerrit-review.googlesource.com/Documentation/intro-user.html#reply-by-email">via email</a>.
-</p>
+<pre>
+$ cd $GODIR/src
+$ [make changes...]
+$ $GODIR/bin/go install cmd/compile
+$ $GODIR/bin/go build [something...] # test the new compiler
+$ $GODIR/bin/go run [something...] # test the new compiler
+$ $GODIR/bin/go test [something...] # test the new compiler
+</pre>
-<p>
-When you have revised the code and are ready for another round of review,
-stage those changes and use <code>git</code> <code>change</code> to update the
-commit.
-To send the updated change for another round of review,
-run <code>git</code> <code>mail</code> again.
-</p>
+The same applies to other internal tools of the Go tool chain,
+such as <code>asm</code>, <code>cover</code>, <code>link</code>, and so on.
+Just recompile and install the tool using <code>go</code>
+<code>install</code> <code>cmd/&lt;TOOL&gt;</code> and then use
+the built Go binary to test it.
+</li>
-<p>
-The reviewer can comment on the new copy, and the process repeats.
-The reviewer approves the change by giving it a positive score
-(+1 or +2) and replying <code>LGTM</code>: looks good to me.
-</p>
+<li>
+In addition to the standard per-package tests, there is a top-level
+test suite in <code>$GODIR/test</code> that contains
+several black-box and regression tests.
+The test suite is run
+by <code>all.bash</code> but you can also run it manually:
-<p>
-You can see a list of your pending changes by running <code>git</code>
-<code>pending</code>, and switch between change branches with <code>git</code>
-<code>change</code> <code><i>&lt;branch&gt;</i></code>.
-</p>
+<pre>
+$ cd $GODIR/test
+$ $GODIR/bin/go run run.go
+</pre>
+</ul>
-<h3 id="sync">Synchronize your client</h3>
+<h3 id="subrepos">Contributing to subrepositories (golang.org/x/...)</h3>
<p>
-While you were working, others might have submitted changes to the repository.
-To update your local branch, run
+If you are contributing a change to a subrepository, obtain the
+Go package using <code>go get</code>.
+For example, to contribute
+to <code>golang.org/x/oauth2</code>, check out the code by running:
</p>
<pre>
-$ git sync
+$ go get -d golang.org/x/oauth2/...
</pre>
<p>
-(In git terms, <code>git</code> <code>sync</code> runs
-<code>git</code> <code>pull</code> <code>-r</code>.)
+Then, change your directory to the package's source directory
+(<code>$GOPATH/src/golang.org/x/oauth2</code>), and follow the
+normal contribution flow.
</p>
-<h3 id="resolving_conflicts">Resolving Conflicts</h3>
+
+<h3 id="cc">Specifying a reviewer / CCing others</h3>
<p>
-If files you were editing have changed, Git does its best to merge the
-remote changes into your local changes.
-It may leave some files to merge by hand.
+Unless explicitly told otherwise, such as in the discussion leading
+up to sending in the change, it's better not to specify a reviewer.
+All changes are automatically CC'ed to the
+<a href="https://groups.google.com/group/golang-codereviews">golang-codereviews@googlegroups.com</a>
+mailing list.
+If this is your first ever change, there may be a moderation
+delay before it appears on the mailing list, to prevent spam.
</p>
<p>
-For example, suppose you have edited <code>sin.go</code> but
-someone else has committed an independent change.
-When you run <code>git</code> <code>sync</code>,
-you will get the (scary-looking) output:
+You can specify a reviewer or CC interested parties
+using the <code>-r</code> or <code>-cc</code> options.
+Both accept a comma-separated list of e-mail addresses:
+</p>
<pre>
-$ git sync
-Failed to merge in the changes.
-Patch failed at 0023 math: improved Sin, Cos and Tan precision for very large arguments
-The copy of the patch that failed is found in:
- /home/you/repo/.git/rebase-apply/patch
-
-When you have resolved this problem, run "git rebase --continue".
-If you prefer to skip this patch, run "git rebase --skip" instead.
-To check out the original branch and stop rebasing, run "git rebase --abort".
+$ git codereview mail -r joe@golang.org -cc mabel@example.com,math-nuts@swtch.com
</pre>
+
+<h3 id="sync">Synchronize your client</h3>
+
<p>
-If this happens, run
+While you were working, others might have submitted changes to the repository.
+To update your local branch, run
</p>
<pre>
-$ git status
+$ git codereview sync
</pre>
<p>
-to see which files failed to merge.
-The output will look something like this:
+(Under the covers this runs
+<code>git</code> <code>pull</code> <code>-r</code>.)
</p>
-<pre>
-rebase in progress; onto a24c3eb
-You are currently rebasing branch 'mcgillicutty' on 'a24c3eb'.
- (fix conflicts and then run "git rebase --continue")
- (use "git rebase --skip" to skip this patch)
- (use "git rebase --abort" to check out the original branch)
-
-Unmerged paths:
- (use "git reset HEAD &lt;file&gt;..." to unstage)
- (use "git add &lt;file&gt;..." to mark resolution)
- <i>both modified: sin.go</i>
-</pre>
+<h3 id="download">Reviewing code by others</h3>
<p>
-The only important part in that transcript is the italicized "both modified"
-line: Git failed to merge your changes with the conflicting change.
-When this happens, Git leaves both sets of edits in the file,
-with conflicts marked by <code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code> and
-<code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code>.
-It is now your job to edit the file to combine them.
-Continuing the example, searching for those strings in <code>sin.go</code>
-might turn up:
+As part of the review process reviewers can propose changes directly (in the
+GitHub workflow this would be someone else attaching commits to a pull request).
+
+You can import these changes proposed by someone else into your local Git repository.
+On the Gerrit review page, click the "Download ▼" link in the upper right
+corner, copy the "Checkout" command and run it from your local Git repo.
+It will look something like this:
</p>
<pre>
- arg = scale(arg)
-&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD
- if arg &lt; 1e9 {
-=======
- if arg &lt; 1e10 {
-&gt;&gt;&gt;&gt;&gt;&gt;&gt; mcgillicutty
- largeReduce(arg)
+$ git fetch https://go.googlesource.com/review refs/changes/21/13245/1 &amp;&amp; git checkout FETCH_HEAD
</pre>
<p>
-Git doesn't show it, but suppose the original text that both edits
-started with was 1e8; you changed it to 1e10 and the other change to 1e9,
-so the correct answer might now be 1e10.
-First, edit the section to remove the markers and leave the correct code:
+To revert, change back to the branch you were working in.
</p>
-<pre>
- arg = scale(arg)
- if arg &lt; 1e10 {
- largeReduce(arg)
-</pre>
+
+<h3 id="git-config">Set up git aliases</h3>
<p>
-Then tell Git that the conflict is resolved by running
+The <code>git-codereview</code> command can be run directly from the shell
+by typing, for instance,
</p>
<pre>
-$ git add sin.go
+$ git codereview sync
</pre>
<p>
-If you had been editing the file, say for debugging, but do not
-care to preserve your changes, you can run
-<code>git</code> <code>reset</code> <code>HEAD</code> <code>sin.go</code>
-to abandon your changes.
-Then run <code>git</code> <code>rebase</code> <code>--continue</code> to
-restore the change commit.
+but it is more convenient to set up aliases for <code>git-codereview</code>'s own
+subcommands, so that the above becomes,
</p>
-<h3 id="download">Reviewing code by others</h3>
+<pre>
+$ git sync
+</pre>
<p>
-As part of the review process reviewers can propose changes directly (in the
-GitHub workflow this would be someone else attaching commits to a pull request).
-
-You can import these changes proposed by someone else into your local Git repository.
-On the Gerrit review page, click the "Download ▼" link in the upper right
-corner, copy the "Checkout" command and run it from your local Git repo. It
-should look something like this:
+The <code>git-codereview</code> subcommands have been chosen to be distinct from
+Git's own, so it's safe to define these aliases.
+To install them, copy this text into your
+Git configuration file (usually <code>.gitconfig</code> in your home directory):
</p>
<pre>
-$ git fetch https://go.googlesource.com/review refs/changes/21/1221/1 &amp;&amp; git checkout FETCH_HEAD
+[alias]
+ change = codereview change
+ gofmt = codereview gofmt
+ mail = codereview mail
+ pending = codereview pending
+ submit = codereview submit
+ sync = codereview sync
</pre>
-<p>
-To revert, change back to the branch you were working in.
-</p>
-<h2 id="submit">Apply the change to the master branch</h2>
+<h3 id="multiple_changes">Sending multiple dependent changes</h3>
<p>
-After the code has been <code>LGTM</code>'ed, an approver may
-apply it to the master branch using the Gerrit UI.
-There is a "Submit" button on the web page for the change
-that appears once the change is approved (marked +2).
+Advanced users may want to stack up related commits in a single branch.
+Gerrit allows for changes to be dependent on each other, forming such a dependency chain.
+Each change will need to be approved and submitted separately but the dependency
+will be visible to reviewers.
</p>
<p>
-This checks the change into the repository.
-The change description will include a link to the code review,
-and the code review will be updated with a link to the change
-in the repository.
-Since the method used to integrate the changes is "Cherry Pick",
-the commit hashes in the repository will be changed by
-the "Submit" operation.
+To send out a group of dependent changes, keep each change as a different commit under
+the same branch, and then run:
</p>
-<h2 id="more">More information</h2>
+<pre>
+$ git codereview mail HEAD
+</pre>
<p>
-In addition to the information here, the Go community maintains a <a
-href="https://golang.org/wiki/CodeReview">CodeReview</a> wiki page.
-Feel free to contribute to this page as you learn the review process.
+Make sure to explicitly specify <code>HEAD</code>, which is usually not required when sending
+single changes.
</p>
diff --git a/doc/devel/release.html b/doc/devel/release.html
index cafca675c0..30d1611509 100644
--- a/doc/devel/release.html
+++ b/doc/devel/release.html
@@ -16,11 +16,11 @@ git checkout <i>release-branch</i>
<p>
Each major Go release is supported until there are two newer major releases.
-For example, Go 1.8 is supported until Go 1.10 is released,
-and Go 1.9 is supported until Go 1.11 is released.
+For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was
+supported until the Go 1.8 release.
We fix critical problems, including <a href="/security">critical security problems</a>,
in supported releases as needed by issuing minor revisions
-(for example, Go 1.9.1, Go 1.9.2, and so on).
+(for example, Go 1.6.1, Go 1.6.2, and so on).
</p>
<h2 id="go1.10">go1.10 (released 2018/02/16)</h2>
@@ -153,7 +153,7 @@ See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.5">Go
</p>
<p>
-go1.8.6 (released 2018/01/22) includes the the same fix in <code>math/big</code>
+go1.8.6 (released 2018/01/22) includes the same fix in <code>math/big</code>
as Go 1.9.3 and was released at the same time.
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.6">Go
1.8.6 milestone</a> on our issue tracker for details.
diff --git a/doc/effective_go.html b/doc/effective_go.html
index 61de824fcd..89c1d08782 100644
--- a/doc/effective_go.html
+++ b/doc/effective_go.html
@@ -3588,8 +3588,7 @@ That's left as an exercise for the reader.
<p>
Let's finish with a complete Go program, a web server.
This one is actually a kind of web re-server.
-Google provides a service at
-<a href="http://chart.apis.google.com">http://chart.apis.google.com</a>
+Google provides a service at <code>chart.apis.google.com</code>
that does automatic formatting of data into charts and graphs.
It's hard to use interactively, though,
because you need to put the data into the URL as a query.
diff --git a/doc/go1.10.html b/doc/go1.10.html
index 4c0e847c05..2974fef9a3 100644
--- a/doc/go1.10.html
+++ b/doc/go1.10.html
@@ -43,9 +43,9 @@ There are no significant changes to the language specification.
</p>
<p><!-- CL 60230 -->
-A corner case involving shifts by untyped constants has been clarified,
+A corner case involving shifts of untyped constants has been clarified,
and as a result the compilers have been updated to allow the index expression
-<code>x[1.0</code>&nbsp;<code>&lt;&lt;</code>&nbsp;<code>s]</code> where <code>s</code> is an untyped constant;
+<code>x[1.0</code>&nbsp;<code>&lt;&lt;</code>&nbsp;<code>s]</code> where <code>s</code> is an unsigned integer;
the <a href="/pkg/go/types/">go/types</a> package already did.
</p>
diff --git a/doc/go_faq.html b/doc/go_faq.html
index f273688705..cc81e49a9b 100644
--- a/doc/go_faq.html
+++ b/doc/go_faq.html
@@ -45,7 +45,7 @@ analysis easy and avoids much of the overhead of C-style include files and
libraries.
<li>
Go's type system has no hierarchy, so no time is spent defining the
-relationships between types. Also, although Go has static types the language
+relationships between types. Also, although Go has static types, the language
attempts to make types feel lighter weight than in typical OO languages.
<li>
Go is fully garbage-collected and provides fundamental support for
@@ -1097,24 +1097,27 @@ The <code>go get</code> command therefore uses HTTPS for safety.
</p>
<p>
-If you use <code>git</code> and prefer to push changes through SSH using your existing key
-it's easy to work around this. For GitHub, try one of these solutions:
+<code>Git</code> can be configured to authenticate over HTTPS or to use SSH in place of HTTPS.
+To authenticate over HTTPS, you can add a line
+to the <code>$HOME/.netrc</code> file that git consults:
</p>
-<ul>
-<li>Manually clone the repository in the expected package directory:
<pre>
-$ cd src/github.com/username
-$ git clone git@github.com:username/package.git
+machine github.com login <i>USERNAME</i> password <i>APIKEY</i>
</pre>
-</li>
-<li>Force <code>git push</code> to use the <code>SSH</code> protocol by appending
-these two lines to <code>~/.gitconfig</code>:
+<p>
+For GitHub accounts, the password can be a
+<a href="https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/">personal access token</a>.
+</p>
+
+<p>
+<code>Git</code> can also be configured to use SSH in place of HTTPS for URLs matching a given prefix.
+For example, to use SSH for all GitHub access,
+add these lines to your <code>~/.gitconfig</code>:
+</p>
<pre>
-[url "git@github.com:"]
- pushInsteadOf = https://github.com/
+[url "ssh://git@github.com/"]
+ insteadOf = https://github.com/
</pre>
-</li>
-</ul>
<h3 id="get_version">
How should I manage package versions using "go get"?</h3>
@@ -1852,18 +1855,19 @@ Why is my trivial program such a large binary?</h3>
<p>
The linker in the <code>gc</code> toolchain
-creates statically-linked binaries by default. All Go binaries therefore include the Go
+creates statically-linked binaries by default.
+All Go binaries therefore include the Go
run-time, along with the run-time type information necessary to support dynamic
type checks, reflection, and even panic-time stack traces.
</p>
<p>
-A simple C "hello, world" program compiled and linked statically using gcc
-on Linux is around 750 kB,
-including an implementation of <code>printf</code>.
-An equivalent Go program using <code>fmt.Printf</code>
-is around 1.5 MB, but
-that includes more powerful run-time support and type information.
+A simple C "hello, world" program compiled and linked statically using
+gcc on Linux is around 750 kB, including an implementation of
+<code>printf</code>.
+An equivalent Go program using
+<code>fmt.Printf</code> weighs a couple of megabytes, but that includes
+more powerful run-time support and type and debugging information.
</p>
<h3 id="unused_variables_and_imports">
@@ -1931,6 +1935,26 @@ eliminating the unused imports issue in practice.
This program is easily connected to most editors to run automatically when a Go source file is written.
</p>
+<h3 id="virus">
+Why does my virus-scanning software think my Go distribution or compiled binary is infected?</h3>
+
+<p>
+This is a common occurrence, especially on Windows machines, and is almost always a false positive.
+Commercial virus scanning programs are often confused by the structure of Go binaries, which
+they don't see as often as those compiled from other languages.
+</p>
+
+<p>
+If you've just installed the Go distribution and the system reports it is infected, that's certainly a mistake.
+To be really thorough, you can verify the download by comparing the checksum with those on the
+<a href="https://golang.org/dl/">downloads page</a>.
+</p>
+
+<p>
+In any case, if you believe the report is in error, please report a bug to the supplier of your virus scanner.
+Maybe in time virus scanners can learn to understand Go programs.
+</p>
+
<h2 id="Performance">Performance</h2>
<h3 id="Why_does_Go_perform_badly_on_benchmark_x">
diff --git a/doc/go_spec.html b/doc/go_spec.html
index 9a166ccdf4..f1300c105a 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
- "Subtitle": "Version of February 1, 2018",
+ "Subtitle": "Version of May 9, 2018",
"Path": "/ref/spec"
}-->
@@ -3051,7 +3051,6 @@ used in an <a href="#Assignments">assignment</a> or initialization of the specia
v, ok = a[x]
v, ok := a[x]
var v, ok = a[x]
-var v, ok T = a[x]
</pre>
<p>
@@ -4161,11 +4160,6 @@ operands and are evaluated at compile time.
Untyped boolean, numeric, and string constants may be used as operands
wherever it is legal to use an operand of boolean, numeric, or string type,
respectively.
-Except for shift operations, if the operands of a binary operation are
-different kinds of untyped constants, the operation and, for non-boolean operations, the result use
-the kind that appears later in this list: integer, rune, floating-point, complex.
-For example, an untyped integer constant divided by an
-untyped complex constant yields an untyped complex constant.
</p>
<p>
@@ -4175,9 +4169,17 @@ an untyped boolean constant. If the left operand of a constant
result is an integer constant; otherwise it is a constant of the same
type as the left operand, which must be of
<a href="#Numeric_types">integer type</a>.
-Applying all other operators to untyped constants results in an untyped
-constant of the same kind (that is, a boolean, integer, floating-point,
-complex, or string constant).
+</p>
+
+<p>
+Any other operation on untyped constants results in an untyped constant of the
+same kind; that is, a boolean, integer, floating-point, complex, or string
+constant.
+If the untyped operands of a binary operation (other than a shift) are of
+different kinds, the result is of the operand's kind that appears later in this
+list: integer, rune, floating-point, complex.
+For example, an untyped integer constant divided by an
+untyped complex constant yields an untyped complex constant.
</p>
<pre>
diff --git a/doc/install-source.html b/doc/install-source.html
index 4ed9487504..1928b0ba9b 100644
--- a/doc/install-source.html
+++ b/doc/install-source.html
@@ -307,7 +307,7 @@ package main
import "fmt"
func main() {
- fmt.Printf("hello, world\n")
+ fmt.Printf("hello, world\n")
}
</pre>
diff --git a/doc/install.html b/doc/install.html
index f17dce5bdd..ee1516ac47 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -106,6 +106,14 @@ variable. You can do this by adding this line to your <code>/etc/profile</code>
export PATH=$PATH:/usr/local/go/bin
</pre>
+<p>
+<b>Note</b>: changes made to a <code>profile</code> file may not apply until the
+next time you log into your computer.
+To apply the changes immediately, just run the shell commands directly
+or execute them from the profile using a command such as
+<code>source $HOME/.profile</code>.
+</p>
+
<h4 id="tarball_non_standard">Installing to a custom location</h4>
<p>
@@ -236,7 +244,7 @@ package main
import "fmt"
func main() {
- fmt.Printf("hello, world\n")
+ fmt.Printf("hello, world\n")
}
</pre>
@@ -278,7 +286,7 @@ If you see the "hello, world" message then your Go installation is working.
<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> to remove it.
+or <code>go</code> <code>clean</code> <code>-i</code> to remove it.
</p>
<p>
diff --git a/doc/progs/error2.go b/doc/progs/error2.go
index 2b0e0c3563..086b6710d3 100644
--- a/doc/progs/error2.go
+++ b/doc/progs/error2.go
@@ -20,11 +20,11 @@ func viewRecord(w http.ResponseWriter, r *http.Request) {
key := datastore.NewKey(c, "Record", r.FormValue("id"), 0, nil)
record := new(Record)
if err := datastore.Get(c, key, record); err != nil {
- http.Error(w, err.Error(), 500)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if err := viewTemplate.Execute(w, record); err != nil {
- http.Error(w, err.Error(), 500)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
diff --git a/doc/progs/error3.go b/doc/progs/error3.go
index e4e57e077b..d9e56b5d64 100644
--- a/doc/progs/error3.go
+++ b/doc/progs/error3.go
@@ -33,7 +33,7 @@ type appHandler func(http.ResponseWriter, *http.Request) error
func (fn appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if err := fn(w, r); err != nil {
- http.Error(w, err.Error(), 500)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
diff --git a/doc/root.html b/doc/root.html
index a5119a9ff8..545b28d2d5 100644
--- a/doc/root.html
+++ b/doc/root.html
@@ -74,7 +74,7 @@ Linux, Mac OS X, Windows, and more.
<div class="left">
<div id="video">
<div class="rootHeading">Featured video</div>
- <iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe>
+ <div class="js-frontpage-video" style="--aspect-ratio-padding: 58.07%;"><iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe></div>
</div>
</div>
@@ -153,6 +153,10 @@ Linux, Mac OS X, Windows, and more.
];
var v = videos[Math.floor(Math.random()*videos.length)];
$('#video iframe').attr('height', v.h).attr('src', v.s);
+ // Compute the aspect ratio (as a percentage) of the video
+ // using the fixed width 415 and the height of the current video, v.h.
+ var ar = 100*v.h/415;
+ $('.js-frontpage-video').attr('style', '--aspect-ratio-padding: ' + ar + '%;');
});
{{end}}