0

In my go app(parent), I import a go library(child) through go get and copy it to the parent directory. For my use, I make some modifications in "child" for extending certain features. I use go module and use "replace" in go.mod to point to the local child(with extended features) path instead of the global $GOPATH.

I am confused how to constantly keep the child in sync with its upstream repo, while retaining my extended features.

//App directory    
Parent.go
--Child/ (copied from $GOPATH)
go.mod

//go.mod
replace github.com/xyz/child => ./Child

Setting up the child as a git-submodule works well in my system. But when the repo is pulled from another system, the child picks up it's go dependencies from $GOPATH from past versions and doesn't map to the correct version.

I an trying to setup git-submodule and go-module to work seamlessly for my app in any environment. I am trying to resolve this for more than a week now. Please help.

pauljeba
  • 760
  • 2
  • 10
  • 27

1 Answers1

0

If I understand you right you should fork the repo, change import paths, keep it updated with upstream and use it.

Another option is to contribute to the third party library.

replace directive is more not for long-term usage but for debugging and non-standard situations.

Nikifor
  • 211
  • 1
  • 4