How to use GoLand to contribute to Go
GoLand is a Go IDE and can be used to write Go code for your applications. But what if you want to work on Go itself and contribute to the programming language? This tutorial describes how you can configure the IDE to do that in a few steps.
Step 1. Clone the Go sources
On the Welcome screen, click Get from Version Control and select Git.
In the URL text field, copy and paste the following URL:
https://go.googlesource.com/go
.In the Directory text field, define a directory where you want to store the Go project.
Click Clone.
In the Checkout From Version Control dialog, click Yes.
Open settings Ctrl+Alt+S and navigate to Enable Go modules integration checkbox is cleared.
. Ensure that the
Step 2. Compile Go
In the Terminal tool window ( ), navigate to the src directory by running the following command:
cd src
.From the src directory, run the following command to start Go compliation:
./make.bash
(for Linux and macOS),make.bat
(for Windows).
Troubleshooting
Error | Possible solution |
---|---|
ERROR: Cannot find <path_to_go>. Set $GOROOT_BOOTSTRAP to a working Go tree >= Go <version>. | Open settings Ctrl+Alt+S and navigate to Environment Variables field, click the Browse button and add the following variable: GOROOT_BOOTSTRAP = <path_to_go_sdk> . | . In the
Step 3. Set the cloned Go project as Go SDK
If you set the root directory of the cloned Go project as the Go SDK for the project, GoLand will use this Go SDK for code completion, code navigation, identifier definition, and other IDE features.
In settings Ctrl+Alt+S, navigate to
.Click the Add SDK button and select Local.
In the file browser, navigate to the root directory of the cloned project and click Open.
Click Apply.
Step 4. Create a branch for your changes
To create a branch in GoLand, navigate to New Branch.
and selectIn the Create New Branch dialog, type the name of a new branch and click OK.
Step 5. Run tests
After you have done all the changes and run the tests that you created for them. You can also run all tests that are included in the Go project.
In the Terminal tool window ( ), navigate to the src directory by running the following command:
cd src
.From the src directory, run the following command to start Go compilation:
./all.bash
(for Linux and macOS),all.bat
(for Windows).
Step 6. Commit your changes
When you are done with your changes, you can commit them to your own fork and then send a pull request for the Go team to have a look at it and merge it back.
Navigate to
Ctrl+Alt+K.Select all files that you want to submit.
In the Commit Message text field, write shortly about your changes.
Press Commit.
Step 7. Add a remote and push to your fork
Add a new remote to the repository that points to your fork of Go (for example, git@github.com:<your_github_account>/go.git
). Then push your changes and open the pull request for Go team. For more information about creating pull requests, see Creating a pull request from a fork at GitHub.
Navigate to
.In the Push Commits dialog, click the origin link in the title of your commit.
Click Define Remote.
In the Name field, enter a name of your fork.
In the URL field, enter URL of your fork and click OK.