This might be a dumb question. But I am a beginner just starting to contribute to open source in some golang project.
One thing I found that cause me alot of headache is that if the project has multiple package and the author uses those package across the packages its hard for me to resolve the import path when I fork the project.
For example
package package2
import (
"github.com/some_author/project_name/package1"
)
If I change some code in package 1, the above will cause problem because the file I changed is in
"github.com/my_github_name/project_name/package1"
so this means that I have to manually change the author name if I change a package that rely on another package I also changed in the same repository
I feel like I might be missing something. This cannot be the idiomatic way of open source contributing. I must be doing something wrong.
评论:
nerr:
problmeo:Instead of working on a copy of the upstream repository (github.com/me/project), work on the repository itself (github.com/upstream/project). Add a new git remote that points to your fork, so you can push your changes to your fork (and then submit a pull request) when you're done.
There is no need to ever touch an import path if you're planning on contributing upstream.
R2A2:good point, I will try that, thanks.
daveddev:I tend to name my remote the origin, and the upstream one upstream. It takes a couple more steps though.
git remote -v git remote rm origin git remote add origin https://github.com/me/project git remote add upstream https://(github.com/upstream/project git remote -v
R2A2:I wouldn't say that this is absolutely wrong, but it is certainly contrary to what the directory path implies.
For me it means I can keep the workflow I'm used to. When I'm working on a feature I just work with the origin as usual, then occasionally pull in changes from upstream, and PR back to upstream. It's much easier when context-switching IMO
