GoLand 2019.2 Help

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

  1. On the Welcome screen, click Check out from Version Control and select Git.

  2. In the URL text field, copy and paste the following URL: https://go.googlesource.com/go.

  3. In the Directory text field, define a directory where you want to store the Go project.

  4. Click Clone.

  5. In the Checkout From Version Control dialog, click Yes.

  6. Open settings Ctrl+Alt+S and navigate to Go | Go modules. Ensure that the Enable Go Modules (vgo) integration checkbox is cleared.

Step 1. Clone the Go sources

Step 2. Compile Go

  1. In the Terminal tool window (View | Tool Windows | Terminal), navigate to the src directory by running the following command:cd src.

  2. From the src directory, run the following command to start Go compliation: ./make.bash (for Linux and macOS), make.bat (for Windows).

Step 2. Compile Go

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 Tools | Terminal. In the Environment Variables field, click the Browse button the Browse button and add the following variable: GOROOT_BOOTSTRAP = <path_to_go_sdk>.

Set GOROOT_BOOTSTRAP

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.

  1. In settings Ctrl+Alt+S, navigate to Go | GOROOT.

  2. Click the Add SDK button the Add SDK button and select Local.

  3. In the file browser, navigate to the root directory of the cloned project and click Open.

  4. Click Apply.

Step 3. Set the root directory of the cloned Go project as the Go SDK for the project

Step 4. Create a branch for your changes

  1. To create a branch in GoLand, navigate to VCS | Git | Branches and select New Branch.

  2. In 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.

  1. In the Terminal tool window (View | Tool Windows | Terminal), navigate to the src directory by running the following command:cd src.

  2. 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.

  1. Navigate to VCS | Commit Ctrl+Alt+K.

  2. Select all files that you want to submit.

  3. In the Commit Message text field, write shortly about your changes.

  4. Press Commit.

Step 6. Commit your changes

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.

  1. Navigate to VCS | Git | Push.

  2. In the Push Commits dialog, click the origin link in the title of your commit.

  3. Click Define Remote.

  4. In the Name field, enter a name of your fork.

  5. In the URL field, enter URL of your fork and click OK.

Step 7. Add a remote and push to your fork
Last modified: 21 August 2019