In this post, I show that contributing to Go repositories is as simple as contributing to any other open-source repo. This is a step-by-step guide to contributing to Go repositories. As an example, I use the main Go repository go.googlesource.com/go.
What we will contribute
I subscribed to Boldly Go: Daily for a year and recently received the following email:
It says nobody cares about the grammatical mistake in the sentence
The functions Alignof and Sizeof take an expression x of any type and return the alignment or size, respectively, of a hypothetical variable v as if v was declared via var v = x
in the Go language specification.
But I care. Let me fix it.
TL;DR: This CL fixes the grammatical error.
“Was” should be changed to “were” because the sentence uses the subjunctive mood, which describes hypothetical or non-real situations. In English, the subjunctive mood often uses “were” instead of “was” for all subjects (I, you, he, she, it, we, they).
Contribution steps
There is an official Contribution Guide, but it is a bit long to read.
I assume you know how to contribute to a project on GitHub. If not, read this guide. I cover only the specifics that apply to most Google software projects.
1. Sign the Google CLA
First, sign the Google Contributor License Agreement with a valid Google Account at the Google CLA.
2. Configure Git authentication
Next, configure authentication so you can push your changes to the Go repo. Log in to the Go Git repositories with the Google account you used to sign the CLA and click Generate password.
Paste the generated script into a bash or zsh shell.
Now you can push to any repository in Go Git.
3. Register with Gerrit
Code review is handled on the Gerrit platform, so sign in with your Google Account. Gerrit differs from GitHub pull requests and can look odd at first, but it is powerful—you may come to like it.
4. Clone the Go repo
We know the spec is located in the go repository.
Clone it locally to make changes.
Gerrit requires commits to include a line like Change-Id: If4d3b3965762c8979d304a82493c9eb1068ee13c.
Install the git-codereview add-on to insert this line automatically.
On my machine, it takes around two minutes to clone the repo and install git-codereview with hooks:
$ git clone https://go.googlesource.com/go && (cd go && go install golang.org/x/review/git-codereview@latest && git-codereview hooks)
Cloning into 'go'...
remote: Sending approximately 431.23 MiB ...
remote: Counting objects: 22, done
remote: Total 639024 (delta 496556), reused 639024 (delta 496556)
Receiving objects: 100% (639024/639024), 431.04 MiB | 6.22 MiB/s, done.
Resolving deltas: 100% (496556/496556), done.
Updating files: 100% (14130/14130), done.
go: downloading golang.org/x/review v1.13.0
5. Fix a typo
Open doc/go_spec.html in your editor and fix the typo.
Create a commit on the branch spec-fix-typo with the following command:
$ git add . && git codereview change spec-fix-typo
git-codereview: created branch spec-fix-typo tracking origin/master.
git-codereview: change updated.
Write a meaningful commit message.
Follow the Git commit message conventions described here. In short, a good commit message looks like:
prefix: summary of changes
Optional multi-line description. Leave a blank line before it.
Can be empty.
Here, prefix is the name of the changed file or directory.
In our simple case, a good one-liner is spec: fix grammar issue.
Verify that the Change-Id line was created:
$ git log -1
commit c53307c3fdf1126eb6cdb1f09f4f9b83759be705 (HEAD -> spec-fix-typo)
Author: Oleksandr Redko <oleksandr.red+github@gmail.com>
Date: Fri Jan 10 17:00:24 2025 +0200
spec: fix grammar issue
Change-Id: If4d3b3965762c8979d304a82493c9eb1068ee13c
6. Wait for review
Next, push your changes to Gerrit so someone from the Go team can review them.
Instead of git push, use:
$ git codereview mail
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.23 KiB | 1.23 MiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2)
remote: Processing changes: new: 1, done
remote:
remote: New Changes:
remote: https://go-review.googlesource.com/c/go/+/642037 spec: fix grammar issue
remote:
To https://go.googlesource.com/go
* [new branch] HEAD -> refs/for/master
Open the link https://go-review.googlesource.com/c/go/+/642037 to see the change.
After some time—usually from a few hours to a couple of weeks—someone will review your change and approve it with +2.
You can read more about the review process.
Hooray! Now the Gopher Robot can merge it into the master branch.
You can see the fixed typo on the Go website.
Conclusion
Contributing to the Go repository is straightforward but has some differences compared to contributing on GitHub. By following the steps above, you can successfully contribute to the Go project. While the process may seem complex at first, it ensures contributions are well managed and maintain high standards. Anyone can contribute to Go—it becomes simple once you get the hang of it. Happy coding!










