On Friday, August 31, 2018 at 12:22:28 PM UTC-5, Victor wrote:
>
> Hello everyone. I'm looking for best practices on how to setup your 
> development environment using Go modules.
>
> Let assume a situation when you work on a project where you write a go 
> package (call it Pkg) and an application (App) that uses that package Pkg 
> and keep writing code in both. Using GOPATH, the process is pretty 
> straightforward: you create your workspace, then you open $GOPATH/src/App 
> project in your IDE and just continue editing .go files in both folders: 
> $GOPATH/src/App and $GOPATH/src/Pkg where Pkg can be in a form "
> github.com/author/pkg" and that way in your App you can import it by the 
> same "github.com/author/pkg" name and everything works since when you 
> build App, it looks for that package in $GOPATH/src/github.com/author/pkg 
> folder and always uses your latest changes. And since you have direct 
> access to that folder in your IDE, you can continue editing Pkg while at 
> the same time editing App.
>
> Now assume a situation where I want to get rid of GOPATH completely and 
> start using modules. That way I'd put my App and Pkg folders in 
> ~/Projects/App and ~/Projects/Pkg (since I don't have to put them in GOPATH 
> any more). But then once App starts using go.mod file (assuming GO111MODULE 
> is auto), it will be driven by "github.com/author/package" and store it 
> in a local cache and not be using ~/Projects/Pkg where I make changes at 
> the same time while working on ~/Projects/App.
>
> What would be the best practice to setup your development environment 
> using Go modules?
>

You'll want to add a replace directive  to the go.mod file to reference the 
copy of your library Pkg on disk, e.g. 

replace github.com/author/package => ../<wherever>/package 


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to