-4

I'm developing a golang project and a shared module simultaneously. I feel the process is annoying If shared module is modified.

steps:

  1. write something in shared module and give it a new GIT tag.
  2. get latest module version in my project
  3. test, if any bug is found, back to step (1)

Can anyone give a more efficient way?

Lin Yu Cheng
  • 667
  • 9
  • 21
  • 5
    Maybe [Can I work entirely outside of VCS on my local filesystem](https://github.com/golang/go/wiki/Modules#can-i-work-entirely-outside-of-vcs-on-my-local-filesystem)? [How to develop and test a local go module](https://stackoverflow.com/questions/60648427/how-to-develop-and-test-a-local-go-module)? https://stackoverflow.com/questions/52328952/how-to-use-a-module-that-is-outside-of-gopath-in-another-module/52330233#52330233?? – JimB Mar 05 '21 at 15:30
  • 2
    That's what the `replace` directive in go.mod is for. Use it. – Volker Mar 05 '21 at 15:36

1 Answers1

0

While you're developing, I'd recommend just using replace directives in your go.mod to make any changes in dependencies instantly visible (regardless of version) to client code.

E.g. if you have package "client" using package "auth":

$SOMEDIR/client/go.mod would replace dependency on client with $SOMEDIR/auth, and now you can just develop the two alongside each other in $SOMEDIR, commit changes to source control, etc.

When you're ready to "ship" it, you'll have to create an actual version for these modules. That is, if you even want auth to be separately usable from client. Consider keeping everything as private as possible (using internal).


Read this official documentation on the subject for more details

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412