On Sat, Apr 10, 2021 at 3:38 AM 'gonutz' via golang-nuts <
[email protected]> wrote:
> Justin Isreael said
>
> "Changes to ProjectB should be immediately available when compiling
> ProjectA."
>
> which is not true when you simply insert a replace in your go.mod file.
>
> My current problem is that I have a main module that uses a library
> module. I want to debug an issue so I insert a print statement in my main
> module. That works. But now I want to insert a print statement in the
> library. How do I do that?
>
> A replace in the go.mod file is of no help here because I still have to
> specify a require with a concrete version or commit hash for the library.
> This means I cannot just change the code in the library module, I also have
> to create a commit and check it in, then go back to my main module and
> udpate not only the replace but also the require in go.mod, every time I
> want to simply place a simple, temporary print statement for debugging
> purposes into the library.
>
Yes I omitted the fact that the "replace" directive implies that there was
already a "require" directive that needs replacing. But I still maintain
that my original suggestion works. I don't see any requirement that your
library be committed or pushed anywhere, or have a real github hosting, for
the case of pure local development between a number of separate modules.
Here is a structure of two module projects, neither of which have any git
configuration:
.
├── projectA
│ ├── go.mod
│ └── main.go
└── projectB
├── go.mod
└── lib.go
// projectB/lib.gopackage projectB
import "fmt"
func Foo() {
fmt.Println("ProjectB")
}
// projectB/go.mod
module mydomain.com/projects/projectB
// projectA/main.gopackage main
import "mydomain.com/projects/projectB"
func main() {
projectB.Foo()
}
// projectA/go.mod
module mydomain.com/projects/projectA
require mydomain.com/projects/projectB v0.0.0
replace mydomain.com/projects/projectB => /tmp/gotesting/projectB
So I didn't have to commit and push my code anywhere and could just use an
arbitrary version for the "require", and then replace. Now I can do local
development across modules. I guess I am missing the pain point here.
> Does anybody have an easy workflow for the common use case?
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/_BqV6Rk15UA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/421ae2eb-fd97-46b4-ab83-979c5e63cf88n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/421ae2eb-fd97-46b4-ab83-979c5e63cf88n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/CAPGFgA1smZ1yAiBLdzYag5cN4_8rL0A3HjTBRwFgJhq_6_UsJg%40mail.gmail.com.