Developing Go SDK and contributing 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 VCS.
In the Get from Version Control dialog, select Git from the Version control list.
In the URL field, 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.
Сlick Clone.
Open settings Control+Alt+S and navigate to Enable Go modules integration checkbox is cleared.
. Ensure that theGo sources include go.mod files that are used for tests. To disable these tests, you need to turn the Go Modules integration off.
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 |
---|---|
| Open settings Control+Alt+S and navigate to Environment Variables field, click the Browse button and add the following variable: |
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 Control+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 OK.
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
Control+Alt+K.Select all files that you want to submit.
In the Commit Message text field, write shortly what changes you have made.
Click 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, refer to 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.