From 48ee689f19c0b27c8a7b2de9d3b26fe6c0d4fa5d Mon Sep 17 00:00:00 2001
From: Filippo Valsorda
+Again, note the use of
First, this function extracts the page title from
-Again, note the use of
To use this handler, we rewrite our
+
Instruction modifiers are appended to the instruction following a period.
The only modifiers are
+Reference: Go ARM64 Assembly Instructions Reference Manual
+
@@ -882,6 +939,12 @@ The value of
+The value of
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 @@
}-->
-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.
-(Note that the
-Sensitive security-related issues should be reported to security@golang.org.
+In addition to the information here, the Go community maintains a
+CodeReview wiki page.
+Feel free to contribute to the wiki as you learn the review process.
+Note that the
-Before you can contribute to the Go project you need to setup a few prerequisites.
-The Go project uses Gerrit, 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 prior to contributing.
-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:
- The
- 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
+Making a change.
-You'll need a web browser and a command line terminal.
-You should already have Git installed.
-
-Gerrit uses Google Accounts for authentication.
-If you don't have a Google Account, you can create an account which
-includes
-a new Gmail email account or create an account associated
-with your existing
-email address.
+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.
-Visit go.googlesource.com
-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
+with your existing
+e-mail address.
-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:
-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.)
-
-Your secret authentication token is now in a
-Now that you have your authentication token, you need to register your
-account with Gerrit.
-To do this, visit
-go-review.googlesource.com/login/.
-Sign in using the same Google Account you used above.
-
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.
-If the copyright holder for your contribution has already completed the
+You can check your currently signed agreements and sign new ones at
+the Google Developers
+Contributor License Agreements 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.
+it does not need to be completed again.
+
+If the copyright holder for the code you are submitting changes—for example,
+if you start contributing code on behalf of a new company—please send mail
+to the
-You can see your currently signed agreements and sign new ones through the Gerrit
-interface.
-To do this, Log into Gerrit,
-then visit the Agreements
-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
+go.googlesource.com,
+a Git server hosted by Google.
+Authentication on the web server is made through your Google account, but
+you also need to configure
-If the copyright holder for the code you are submitting changes — for example,
-if you start contributing code on behalf of a new company — please send email
-to golang-dev and let us know, so that we can make sure an appropriate agreement is
-completed and update the
+To register your account, visit
+go-review.googlesource.com/login/ and sign in once using the same Google Account you used above.
Changes to Go must be reviewed before they are accepted, no matter who makes the change.
-A custom git command called
Install the
Make sure
On Windows, when using git-bash you must make sure that
-
+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 filing a new issue
+or by claiming an existing issue.
-Note to Git aficionados:
-The
-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
-
-The
+When planning work, please note that the Go project follows a six-month development cycle.
+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.
+
-but it is more convenient to set up aliases for
+Sensitive security-related issues (only!) should be reported to security@golang.org.
+
-The
+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.
-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
+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.
+
+This is an overview of the overall process:
+ After installing the
-to learn more about its commands.
-You can also read the command documentation.
+The rest of this section describes these steps in more detail.
-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
-Before undertaking to write something new for the Go project,
-please file an issue
-(or claim an existing issue).
-Significant changes must go through the
-change proposal process
-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
-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
-When planning work, please note that the Go project follows a six-month development cycle.
-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
-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 scratch repository to practice
-making a change.
+The tool also checks that you've
+run
+If you need to edit the files again, you can stage the new changes and
+re-run
-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
-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 written and tested your code, 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:
+(To build under Windows use
-Most Go installations use a release branch, but new changes should
-only be made based on the master branch.
-(In Git terms,
-If you are contributing a change to a subrepository, obtain the
-Go package using
-Then, change your directory to the package's source directory
-(
+If you get an error instead, check the
+Troubleshooting mail errors section.
+
-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
+suggested commit message format, the issue will be updated in a few minutes by a bot,
+linking your Gerrit change to it in the comments.
-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
-change log and in the New files that you contribute should use the standard copyright header:
+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
+
-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.
-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,
-
-Once you have the changes queued up, you will want to commit them.
-In the Go contribution workflow this is done with a
-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 git-codereview documentation for details.
+Here is an example of a good one:
-The name <branch> 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.
-(In Git terms,
-As the
-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.
-After editing, the template might now read:
+Add any relevant information, such as benchmark data if the change
+afects performance.
+The benchcmp
+tool is conventionally used to format
+benchmark data for change descriptions.
+The special notation "Fixes #12345" associates the change with issue 12345 in the
+Go issue tracker.
+When this change is eventually applied, the issue
+tracker will automatically mark the issue as fixed.
+
+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.
+
+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".
+
-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.
-The special notation "Fixes #159" associates the change with issue 159 in the
-Go issue tracker.
-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
-GitHub Issue Tracker documentation.)
+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:
-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.
-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.
-If you wish to do more editing, re-stage your changes using
-
-to update the change description and incorporate the staged changes.
-The change description contains a
+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.
-(In Git terms,
-You've written and tested your code, 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:
-(To build under Windows use
-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).
+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.
+
+If your change has been approved for a few days without being
+submitted, feel free to write a comment in Gerrit requesting
+submission.
+
-Once the change is ready, send it for review.
-This is similar to a
-(In Git terms,
-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
+change log and in the
-The code review server assigns your change an issue number and URL,
-which
+(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.
+
-The most common way that the
-You need to either add the email address listed to the CLA or set this repo to use
-another email address already approved.
-
-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:
-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:
-Finally try to resend with:
+Then retry by running:
-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
-golang-codereviews@googlegroups.com
-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.
-
-You can specify a reviewer or CC interested parties
-using the
-Running
-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.
-
-You may respond to review comments through the web interface or
-via email.
-
-When you have revised the code and are ready for another round of review,
-stage those changes and use
-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
-You can see a list of your pending changes by running
-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
-(In git terms,
-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
+golang-codereviews@googlegroups.com
+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.
-For example, suppose you have edited
-If this happens, run
+While you were working, others might have submitted changes to the repository.
+To update your local branch, run
-to see which files failed to merge.
-The output will look something like this:
+(Under the covers this runs
+
-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
-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.
-Then tell Git that the conflict is resolved by running
+The
-If you had been editing the file, say for debugging, but do not
-care to preserve your changes, you can run
-
-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
-To revert, change back to the branch you were working in.
-
-After the code has been
-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:
-In addition to the information here, the Go community maintains a CodeReview wiki page.
-Feel free to contribute to this page as you learn the review process.
+Make sure to explicitly specify
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 critical security problems,
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).
_
to ignore the error
+return value from loadPage
. This is done here for simplicity
+and generally considered bad practice. We will attend to this later.
+r.URL.Path
,
the path component of the request URL.
@@ -282,12 +288,6 @@ The function then loads the page data, formats the page with a string of simple
HTML, and writes it to w
, the http.ResponseWriter
.
_
to ignore the error
-return value from loadPage
. This is done here for simplicity
-and generally considered bad practice. We will attend to this later.
-main
function to
initialize http
using the viewHandler
to handle
diff --git a/doc/asm.html b/doc/asm.html
index 3a05d46aeb..f2f8fad576 100644
--- a/doc/asm.html
+++ b/doc/asm.html
@@ -738,6 +738,13 @@ The other codes are ->
(arithmetic right shift),
The ARM64 port is in an experimental state.
R18
is the "platform register", reserved on the Apple platform.
+R27
and R28
are reserved by the compiler and linker.
+R29
is the frame pointer.
+R30
is the link register.
+P
(postincrement) and W
@@ -752,11 +759,61 @@ Addressing modes:
+(R5, R6)
: Register pair for LDP
/STP
.
+R0->16
+
+R0>>16
+
+R0<<16
+
+R0@>16
:
+These are the same as on the 32-bit ARM.
+$(8<<12)
:
+Left shift the immediate value 8
by 12
bits.
+8(R0)
:
+Add the value of R0
and 8
.
+(R2)(R0)
:
+The location at R0
plus R2
.
+R0.UXTB
+
+R0.UXTB<<imm
:
+UXTB
: extract an 8-bit value from the low-order bits of R0
and zero-extend it to the size of R0
.
+R0.UXTB<<imm
: left shift the result of R0.UXTB
by imm
bits.
+The imm
value can be 0, 1, 2, 3, or 4.
+The other extensions include UXTH
(16-bit), UXTW
(32-bit), and UXTX
(64-bit).
+R0.SXTB
+
+R0.SXTB<<imm
:
+SXTB
: extract an 8-bit value from the low-order bits of R0
and sign-extend it to the size of R0
.
+R0.SXTB<<imm
: left shift the result of R0.SXTB
by imm
bits.
+The imm
value can be 0, 1, 2, 3, or 4.
+The other extensions include SXTH
(16-bit), SXTW
(32-bit), and SXTX
(64-bit).
+(R5, R6)
: Register pair for LDAXP
/LDP
/LDXP
/STLXP
/STP
/STP
.
64-bit PowerPC, a.k.a. ppc64
GOMIPS
environment variable (hardfloat
or
GOMIPS_hardfloat
or GOMIPS_softfloat
.
GOMIPS64
environment variable (hardfloat
or
+softfloat
) is made available to assembly code by predefining either
+GOMIPS64_hardfloat
or GOMIPS64_softfloat
.
+Unsupported opcodes
gccgo
frontend lives elsewhere;
-see Contributing to gccgo.)
+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.
Becoming a contributor
+gccgo
front end lives elsewhere;
+see Contributing to gccgo.
+Becoming a contributor
+
+Overview
Automatically set up & diagnose your development environment
+
+
+
git
+is configured to create commits with that account's e-mail address.
+git-codereview
by running
+go get -u golang.org/x/review/git-codereview
+go-contrib-init
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:
@@ -45,66 +71,61 @@ $ go-contrib-init
Configure Git to use Gerrit
-Step 0: Select a Google Account
Step 1: Sign in to googlesource and generate a password
-
Step 2: Run the provided script
+$ git config --global user.email # check current global config
+$ git config user.email # check current local config
+
.gitcookies
file
-and Git is configured to use this file.
+To change the configured address:
Step 3: Register with Gerrit
+
+$ git config --global user.email name@example.com # change global config
+$ git config user.email name@example.com # change local config
+
-Contributor License Agreement
+Step 1: Contributor License Agreement
-Which CLA
golang-dev
+mailing list.
+This will let us know the situation so we can make sure an appropriate agreement is
+completed and update the AUTHORS
file.
Completing the CLA
+
+Step 2: Configure git authentication
git
on your computer to access it.
+Follow this steps:
+
+
+.gitcookies
file.
+If you are using a Windows computer and running cmd
,
+you should instead follow the instructions in the yellow box to run the command;
+otherwise run the regular script.
+Step 3: Create a Gerrit account
+
AUTHORS
file.
+Gerrit is an open-source tool used by Go maintainers to discuss and review
+code submissions.
+Preparing a Development Environment for Contributing
+Step 4: Install the git-codereview command
-Setting up Git for submission to Gerrit
git-codereview
, discussed below,
-helps manage the code review process through a Google-hosted
-instance of Gerrit.
+A custom git
command called git-codereview
+simplifies sending changes to Gerrit.
Install the git-codereview command
git-codereview
command by running,
git-codereview
is installed in your shell path, so that the
-git
command can find it. Check that
+git
command can find it.
+Check that
@@ -185,439 +242,686 @@ prints help text, not an error.
git-codereview.exe
is in your git exec-path.
+git-codereview.exe
is in your git
exec-path.
Run git --exec-path
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.
+Before contributing code
+
+Check the issue tracker
+
git-codereview
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 issue tracker is
+always the first place to go.
+Issues are triaged to categorize them and manage the workflow.
Change-Id
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
-git-codereview
hooks
.
+Most issues will be marked with one of the following workflow labels:
Set up git aliases
+
+
+
+Open an issue for any new problem
git-codereview
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.
-$ git codereview sync
-
+git-codereview
's own
-subcommands, so that the above becomes,
+Changes in general other than bug and documentation fixes
+must go through the
+change proposal process
+before they can be accepted.
-$ git sync
-
+Sending a change via GitHub
git-codereview
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
+GitHub flow
+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.
+.gitconfig
in your home directory):
+Some things to keep in mind:
+
+
+Sending a change via Gerrit
+
+Overview
+
+
+
-[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
+Understanding the git-codereview command
+git
codereview
change
; that
+will create or amend a single commit in the branch.
+
+$ 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.]
+
+git-codereview
command, you can runall.bash
.
+
+$ ./all.bash # recompile and test
+
+git
+codereview
mail
(which doesn't use e-mail, despite the name).
-$ git codereview help
+$ git codereview mail # send changes to Gerrit
+
+
+$ [edit files...]
+$ git add [files...]
+$ git codereview change # update same commit
+$ git codereview mail # send to Gerrit again
+Making a Contribution
-
-Discuss your design
+Step 1: Clone the Go source code
GOPATH
.
+Either clone from
+go.googlesource.com
or from GitHub:
+$ git clone https://github.com/golang/go # or https://go.googlesource.com/go
+$ cd go
+
+
+Step 2: Prepare changes in a new branch
+
git
commands to create a branch and add changes to the
+staging area:
+$ git checkout -b mybranch
+$ [edit files...]
+$ git add [files...]
+
+
git commit
, use git codereview change
.
+$ git codereview change
+(open $EDITOR)
+
+
git
codereview
change
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:
Not sure what change to make?
+
+Change-Id: I2fbdbffb3aab626c4b6f56348861b7909e3e8990
+
go
fmt
over the source code, and that
+the commit message follows the suggested format.
Making a change
+git
codereview
change
: each subsequent
+run will amend the existing commit while preserving the Change-Id.
+Getting Go Source
git
rebase
to
+squash them together
+into a single one.
Step 3: Test your changes
+
-$ git clone https://go.googlesource.com/go
-$ cd go
+$ cd go/src
+$ ./all.bash
-Contributing to the main Go tree
+all.bat
; this also requires
+setting the environment variable GOROOT_BOOTSTRAP
to the
+directory holding the Go tree for the bootstrap compiler.)
+
-(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,
-$ git checkout master
-$ git sync
+ALL TESTS PASSED
git
sync
runs
-git
pull
-r
.)
+You can use make.bash
instead of all.bash
+to just build the compiler and standard packages without running the test suite.
+Once the go
tool is built, it will be installed as bin/go
+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 test your changes quickly.
Contributing to subrepositories (golang.org/x/...)
+Step 4: Send changes for review
go get
. For example, to contribute
-to golang.org/x/oauth2
, 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 mail
sub-command which, despite its name, doesn't
+directly mail anything; it just sends the change to Gerrit:
-$ go get -d golang.org/x/oauth2/...
+$ git codereview mail
$GOPATH/src/golang.org/x/oauth2
).
+Gerrit assigns your change a number and URL, which git
codereview
mail
will print, something like:
Make your changes
+
+remote: New Changes:
+remote: https://go-review.googlesource.com/99999 math: improved Sin, Cos and Tan precision for very large arguments
+
+
+Copyright
+
+Step 5: Revise changes after a review
CONTRIBUTORS
file and perhaps the AUTHORS
file.
-These files are automatically generated from the commit logs periodically.
-The AUTHORS
file defines who “The Go
-Authors”—the copyright holders—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
+using e-mail
+if you prefer.
git
codereview
change
:
+
-// 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
Commit your changes
-
git
add
,
-git
rm
,
-and
-git
mv
.
+Again, make sure that you always keep a single commit in each branch.
+If you add more
+commits by mistake, you can use git rebase
to
+squash them together
+into a single one.
Good commit messages
+
git
-change
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.
-$ git change <branch>
+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
+First line
+
git
change
<branch>
-runs git
checkout
-b
branch
,
-then git
branch
--set-upstream-to
origin/master
,
-then git
commit
.)
+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.
git
commit
is the final step, Git will open an
-editor to ask for a commit message. (It uses the editor named by
-the $EDITOR
environment variable,
-vi
by default.)
-
-The file will look like:
+Follow the first line by a blank line.
-
-# 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
-#
-
+Main content
-math: improve Sin, Cos and Tan precision for very large arguments
+
+
+Referencing issues
-The existing implementation has poor numerical properties for
-large arguments, so use the McGillicutty algorithm to improve
-accuracy above 1e10.
+The review process
Common beginner mistakes
+
+
+
+
+Only trivial or cosmetic changes will be accepted without an associated issue.
+R=go1.12
,
+which means that it will be reviewed later when the tree opens for a new
+development window.
+You can add R=go1.XX
as a comment yourself
+if you know that it's not the correct time frame for the change.
+Trybots
+
git
add
, 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
+Build Dashboard 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.
-$ git change
-
+Reviews
Change-Id
line near the bottom,
-added by a Git commit hook during the initial
-git
change
.
-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.
+git
change
with no branch name
-runs git
commit
--amend
.)
+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.
Testing
+Voting conventions
-$ cd go/src
-$ ./all.bash
-
+
+
+
+Submitting an approved change
all.bat
.)
+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".
-"ALL TESTS PASSED".
-
+Send the change for review
+
+More information
git push
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 CodeReview wiki page.
+Feel free to contribute to this page as you learn more about the review process.
-$ git mail
-
+
+
+Miscellaneous topics
git
mail
pushes the local committed
-changes to Gerrit using git
push
origin
-HEAD:refs/for/master
.)
+This section collects a number of other comments that are
+outside the issue/edit/code review/submit process itself.
Copyright headers
+
CONTRIBUTORS
file and perhaps the AUTHORS
file.
+These files are automatically generated from the commit logs periodically.
+The AUTHORS
file defines who “The Go
+Authors”—the copyright holders—are.
git
mail
will print, something like:
+New files that you contribute should use the standard copyright header:
-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.
-Troubleshooting
+Troubleshooting mail errors
git mail
command fails is because the
-email address used has not gone through the setup above.
+The most common way that the git
codereview
mail
+command fails is because the e-mail address in the commit does not match the one
+that you used during the registration process.
+
If you see something like...
@@ -645,8 +945,7 @@ $ git config user.email email@address.com
@@ -654,244 +953,239 @@ $ git commit --amend --author="Author Name <email@address.com>"
-$ git mail
+$ git codereview mail
-Specifying a reviewer / CCing others
-Quickly testing your changes
-r
or -cc
options.
-Both accept a comma-separated list of email addresses:
+Running all.bash
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.
+
-make.bash
instead of all.bash
+to only rebuild the Go tool chain without running the whole test suite.
+Or you
+can run run.bash
to only run the whole test suite without rebuilding
+the tool chain.
+You can think of all.bash
as make.bash
+followed by run.bash
.
+$GODIR
.
+The go
tool built by $GODIR/make.bash
will be installed
+in $GODIR/bin/go
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 go
test
+using it:
+
-$ git mail -r joe@golang.org -cc mabel@example.com,math-nuts@swtch.com
+$ cd <MYPROJECTDIR>
+$ $GODIR/bin/go test
+Going through the review process
-
-git
mail
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
-via email.
-Revise and resend
+
+$ cd $GODIR/src/hash/sha1
+$ [make changes...]
+$ $GODIR/bin/go test .
+
+compile
tool (which is the internal binary invoked
+by go
build
to compile each single package).
+After that, you will want to test it by compiling or running something.
-
+$ 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
+
-git
change
to update the
-commit.
-To send the updated change for another round of review,
-run git
mail
again.
-asm
, cover
, link
, and so on.
+Just recompile and install the tool using go
+install
cmd/<TOOL>
and then use
+the built Go binary to test it.
+LGTM
: looks good to me.
-$GODIR/test
that contains
+several black-box and regression tests.
+The test suite is run
+by all.bash
but you can also run it manually:
-git
-pending
, and switch between change branches with git
-change
<branch>
.
-
+$ cd $GODIR/test
+$ $GODIR/bin/go run run.go
+
+Synchronize your client
+Contributing to subrepositories (golang.org/x/...)
go get
.
+For example, to contribute
+to golang.org/x/oauth2
, check out the code by running:
-$ git sync
+$ go get -d golang.org/x/oauth2/...
git
sync
runs
-git
pull
-r
.)
+Then, change your directory to the package's source directory
+($GOPATH/src/golang.org/x/oauth2
), and follow the
+normal contribution flow.
Resolving Conflicts
+
+Specifying a reviewer / CCing others
sin.go
but
-someone else has committed an independent change.
-When you run git
sync
,
-you will get the (scary-looking) output:
+You can specify a reviewer or CC interested parties
+using the -r
or -cc
options.
+Both accept a comma-separated list of e-mail addresses:
+
-$ 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
+
+Synchronize your client
+
-$ git status
+$ git codereview sync
git
pull
-r
.)
-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 <file>..." to unstage)
- (use "git add <file>..." to mark resolution)
- both modified: sin.go
-
+Reviewing code by others
<<<<<<<
and
->>>>>>>
.
-It is now your job to edit the file to combine them.
-Continuing the example, searching for those strings in sin.go
-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:
- arg = scale(arg)
-<<<<<<< HEAD
- if arg < 1e9 {
-=======
- if arg < 1e10 {
->>>>>>> mcgillicutty
- largeReduce(arg)
+$ git fetch https://go.googlesource.com/review refs/changes/21/13245/1 && git checkout FETCH_HEAD
- arg = scale(arg)
- if arg < 1e10 {
- largeReduce(arg)
-
+
+Set up git aliases
git-codereview
command can be run directly from the shell
+by typing, for instance,
-$ git add sin.go
+$ git codereview sync
git
reset
HEAD
sin.go
-to abandon your changes.
-Then run git
rebase
--continue
to
-restore the change commit.
+but it is more convenient to set up aliases for git-codereview
's own
+subcommands, so that the above becomes,
Reviewing code by others
+
+$ git sync
+
git-codereview
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 .gitconfig
in your home directory):
-$ git fetch https://go.googlesource.com/review refs/changes/21/1221/1 && git checkout FETCH_HEAD
+[alias]
+ change = codereview change
+ gofmt = codereview gofmt
+ mail = codereview mail
+ pending = codereview pending
+ submit = codereview submit
+ sync = codereview sync
-Apply the change to the master branch
+Sending multiple dependent changes
LGTM
'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.
More information
+
+$ git codereview mail HEAD
+
HEAD
, which is usually not required when sending
+single changes.
go1.10 (released 2018/02/16)
@@ -153,7 +153,7 @@ See the Go
-go1.8.6 (released 2018/01/22) includes the the same fix in math/big
+go1.8.6 (released 2018/01/22) includes the same fix in math/big
as Go 1.9.3 and was released at the same time.
See the Go
1.8.6 milestone 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.
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
-http://chart.apis.google.com
+Google provides a service at chart.apis.google.com
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.
-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
-x[1.0
<<
s]
where s
is an untyped constant;
+x[1.0
<<
s]
where s
is an unsigned integer;
the go/types package already did.
go get
command therefore uses HTTPS for safety.
-If you use git
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:
+Git
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 $HOME/.netrc
file that git consults:
-$ cd src/github.com/username -$ git clone git@github.com:username/package.git +machine github.com login USERNAME password APIKEY-
git push
to use the SSH
protocol by appending
-these two lines to ~/.gitconfig
:
++For GitHub accounts, the password can be a +personal access token. +
+ +
+Git
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 ~/.gitconfig
:
+
-[url "git@github.com:"] - pushInsteadOf = https://github.com/ +[url "ssh://git@github.com/"] + insteadOf = https://github.com/-
The linker in the gc
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.
-A simple C "hello, world" program compiled and linked statically using gcc
-on Linux is around 750 kB,
-including an implementation of printf
.
-An equivalent Go program using fmt.Printf
-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
+printf
.
+An equivalent Go program using
+fmt.Printf
weighs a couple of megabytes, but that includes
+more powerful run-time support and type and debugging information.
+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. +
+ ++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 +downloads page. +
+ ++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. +
+@@ -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.
@@ -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 integer type. -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). +
+ ++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.
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") }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
/etc/profile
export PATH=$PATH:/usr/local/go/bin
+
+Note: changes made to a profile
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
+source $HOME/.profile
.
+
@@ -236,7 +244,7 @@ package main import "fmt" func main() { - fmt.Printf("hello, world\n") + fmt.Printf("hello, world\n") } @@ -278,7 +286,7 @@ If you see the "hello, world" message then your Go installation is working.
You can run go
install
to install the binary into
your workspace's bin
directory
-or go
clean
to remove it.
+or go
clean
-i
to remove it.
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.