Golang Project Fork Problem

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Problem

A job was changed in April, and the new job was developed using Golang. When I fork a piece of code in the Code warehouse ready to be developed in my own repo, I find the problem of Golang fork.

SOURCE Repo:example.com/group/tool.git
After fork:example.com/my/tool.git

So I used go get example.com/my/tool to download my repo preparation work and found that GOPATH there are still group/tool . The reason of course is that the import package in the code is used in this way:

import "example/group/tool/module"

So if I'm going to run normally, I have to change it to:

import "example/my/tool/module"

And then you have to change it back before you finish the pull request. This is obviously not the right way to work.

Solve

Having this problem after the Internet search, obviously not only I alone have this problem. This article should be a brief summary of how this should be done.

1. Fork Repo

Fork first and get a repo of your own:example.com/my/tool.git

2. Download the source Repo code

go get  example.com/group/tool"

At GOPATH this time you have all the code and dependencies have been downloaded.

3. Add Remote

Enter the project directory and add remote to git repo

cd $GOPATH/src/example.com/group/toolgit remote add fork example.com/my/tool.git

4. Push

After the previous steps have been completed, the code can be modified, and then the following is the way to push:

git push fork

Reference

    1. Http://blog.campoy.cat/2014/03/github-and-go-forking-pull-requests-and.html
    2. https://splice.com/blog/contributing-open-source-git-repositories-go/
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.