gomod is it ok to clone a remote into a local directory ?

168 views
Skip to first unread message

clément auger

unread,
May 1, 2021, 10:16:40 AM5/1/21
to golang-nuts
Hello,

While toying in some projects i ended using go mod replace directive to point to a local directory containing a git clone of a remote, that i know will need some modifications.

something like
$ git clone github.com/anacrolix/dht dht
$ cat go.mod

module github.com/clementauger/dplay

go 1.16

replace github.com/anacrolix/dht => ./dht

require (
    github.com/anacrolix/dht v1.0.1 // indirect
    github.com/anacrolix/dht/v2 v2.9.0 // indirect
)

is it intended or am i over using it ?

Do you recommend to commit the remote into my repository to keep my dirty fork along the rest of the code and keep things straight forward to re compile ?

Do you think it is a good idea to map the local fork to a remote branch as part of a larger model to drive code management ?

i would prefer to get that right upfront, i know the pain i will have to handle mass import path update, it is so terribly boring (and gomod has made it easy so far!).

I might have missed it but i can not find much about these in https://blog.golang.org/using-go-modules

It is not very helpful.

thanks for interest and suggestions.

Adam Azarchs

unread,
May 4, 2021, 3:28:06 PM5/4/21
to golang-nuts
That's a totally reasonable thing to do, and in fact co-developing two modules the way you are describing is probably one of the best use cases for `replace` directives.  Though, keep in mind that replace directives won't actually be honored by any packages which depend on yours (in this example github.com/clementauger/dplay), so it would be a good idea to try to eventually upstream whatever changes you've made to the source repository at github.com/anacrolix/dht and then remove the `replace` directive.
Reply all
Reply to author
Forward
0 new messages