How can I fork a module that uses /internal ?

79 views
Skip to first unread message

brad.be...@gmail.com

unread,
Jul 25, 2020, 8:46:15 PM7/25/20
to golang-nuts
Hi folks.  I was unable to find a good answer online already.  The closest I found was https://stackoverflow.com/questions/14323872/using-forked-package-import-in-go which suggests using the replace directive in go.mod.

I am using Go 1.14, with all projects located outside of GOPATH.

My exact situation:  I've forked https://github.com/sclevine/agouti to https://github.com/Bradbev/agouti.  Originally I renamed all instances of "sclevine" to "Bradbev" - this works, but doesn't feel right.  Presumably future PR's will be a hassle due to the import changes.
I'm trying to fix it locally before pushing up.  So, what I have locally is
1) A new module agout_test, which contains "replace github.com/bradbev/agouti => ../agouti" in go.mod so that my test project references a local copy
2) A local copy of bradbev/agouti at ../agouti.

Without changes (ie, import paths ARE rewritten), this works.  When I change my local agouti imports back to "sclevine", and add "replace github.com/sclevine/agouti => github.com/bradbev/agouti" to ../agouti/go.mod, my test complains with:

✘-1 ~/development/gomod/agouti_test 

22:51 $ go build main.go && ./main

../agouti/selectable.go:5:2: use of internal package github.com/sclevine/agouti/internal/element not allowed

../agouti/multiselection.go:3:8: use of internal package github.com/sclevine/agouti/internal/target not allowed


This suggests to me that the replace directive is working, but is being disallowed for "/internal" packages.  

What is the correct way to fork this module please?

Thanks,
Brad

Denis Cheremisov

unread,
Jul 25, 2020, 9:03:22 PM7/25/20
to golang-nuts
As soon as I understand you can just keep their module name in `go.mod` and that's it.

воскресенье, 26 июля 2020 г. в 03:46:15 UTC+3, brad.be...@gmail.com:

Brad Beveridge

unread,
Jul 26, 2020, 12:11:58 AM7/26/20
to golang-nuts
Thank you very much!  I have no idea why I thought I needed to change go.mod.
I did run into some strange effects changing my local version back to "sclevine" though - I also needed to remove the cached versions in go/pkg. Thanks again!

Brad 

Reply all
Reply to author
Forward
0 new messages