Contributing to golang based project on github - collaboration best practice

189 views
Skip to first unread message

Nicholas Yue

unread,
Feb 2, 2021, 10:17:40 PMFeb 2
to golang-nuts
Hi,

  I am relatively new to golang coming from a C++/Python world.

  When contributing to C++/Python projects on GitHub, I usually fork the project, make changes to hit and submit a pull request to the author/maintainer.

  I found that the above didn't work for me.

  I am hoping to contribute to the following project

  
  I am trying to ascertain if my challenges is because Golang has specific ways for contribution or the above project is setup differently. I can't tell as I am new to Golang.

  I clone the forked project to $HOME/go/src/github/scipipe and testing it in another directory. I found that whenever I run my small test program, it pulls from some archive rather than my cloned repository and hence is not able to see the changes I made.

  Is there some special way to import the module so that it picked my clone directory rather than pulling down a zip archive versioned copy ?

```
package main

import (
// Import the SciPipe package, aliased to 'sp'
)

func main() {
// Init workflow with a name, and max concurrent tasks
wf := sp.NewWorkflow("hello_world", 4)

// Initialize processes and set output file paths
hello := wf.NewProc("hello", "echo 'Hello ' > {o:out}")
world := wf.NewProc("world", "echo $(cat {i:in}) World >> {o:out}")

// Connect network
world.In("in").From(hello.Out("out"))

wf.Nicholas() // Failed to find this new exported function I added
}
```

Cheers

Shulhan

unread,
Feb 2, 2021, 11:57:02 PMFeb 2
to Nicholas Yue, golang-nuts


> On 3 Feb 2021, at 10.17, Nicholas Yue <yue.ni...@gmail.com> wrote:
>
> Hi,
>
> I am relatively new to golang coming from a C++/Python world.
>
> When contributing to C++/Python projects on GitHub, I usually fork the project, make changes to hit and submit a pull request to the author/maintainer.
>
> I found that the above didn't work for me.
>
> I am hoping to contribute to the following project
>
> https://github.com/scipipe/scipipe
>
> I am trying to ascertain if my challenges is because Golang has specific ways for contribution or the above project is setup differently. I can't tell as I am new to Golang.
>
> I clone the forked project to $HOME/go/src/github/scipipe and testing it in another directory. I found that whenever I run my small test program, it pulls from some archive rather than my cloned repository and hence is not able to see the changes I made.
>
> Is there some special way to import the module so that it picked my clone directory rather than pulling down a zip archive versioned copy ?
>


Inside the go.mod file in your test directory, add the "replace" directive. Something like this may works,

----
module mytestmodule

replace github.com/scipipe/scipipe => ../path/to/your/clone
----

More on Go modules,

* https://blog.golang.org/using-go-modules
* https://golang.org/ref/mod

Volker Dobler

unread,
Feb 3, 2021, 1:21:19 AMFeb 3
to golang-nuts
You either have to use the "replace" directive in go.mod, or:
Do not work on the fork. Do your work on a plain _clone_ of the
repo (which works without "replace"ing dependencies).
To create a Github PR: git push to your fork (add it as an additional
git remote) and create the PR. The "fork" is just a vehicle for a
Github PR and nothing you do work on (or try to build).

V.

Adrian Ho

unread,
Feb 3, 2021, 5:31:04 AMFeb 3
to golan...@googlegroups.com
On 3/2/21 2:21 pm, Volker Dobler wrote:
> To create a Github PR: git push to your fork (add it as an additional
> git remote) and create the PR. The "fork" is just a vehicle for a
> Github PR and nothing you do work on (or try to build).
>
For a concrete example of what Volker's talking about, see the `git`
commands and general workflow in Homebrew's docs on creating pull
requests: https://docs.brew.sh/How-To-Open-a-Homebrew-Pull-Request

--
Best Regards,
Adrian

Nicholas Yue

unread,
Feb 3, 2021, 1:24:12 PMFeb 3
to golang-nuts
Thank you for the different approaches.

I have settled on the go.mod approach as proposed by Shulhan.

Cheers

Sachin maurya

unread,
Jun 14, 2021, 3:35:22 PMJun 14
to golang-nuts

Amnon

unread,
Jun 15, 2021, 12:11:48 AMJun 15
to golang-nuts
This needs to be updated for post-GOPATH modules.
Reply all
Reply to author
Forward
0 new messages