New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go module dependency debugging workflow #45467
Comments
Take a look at Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For questions please refer to https://github.com/golang/go/wiki/Questions |
My Stackoverflow question for this has been closed, three people said it was opinion-based. I started a new conversation on golang-nuts, thanks for pointing me at it. Still I would consider this a bug in the sense that I was able to do what I asked in the last Go version but Go 1.16 defaults to module mode and GOPATH mode is about to be removed completely so I am not able to achieve what I want anymore. Seems to me like a flaw in the design of modules or maybe a lack of a feature for supporting this in which case we could make this issue a proposal? |
replace can point to local paths |
Yes sure,
|
That's not true. According to the doc
|
@ZekeLu You are right! I must have had a bug in my workflow. I was sure that the changes after replacing the dependency had no effect. Now that I tried it on a fresh example module it works. Modules are hard andl confusing. |
What version of Go are you using (
go version
)?go version go1.16.2 windows/amd64
Does this issue reproduce with the latest release?
Yes.
What did you do?
The scenario: I am creating module
mp3player
, my main program. It uses library modulemp3
. While debugging I insert print statements in my main program. They show. Now I need to go deeper and want to insert a print statement in the library code. How do I do that?I found that the code that is actually compiled is the copy of the library with the version specified by my
go.mod
file in the go mod cache (GOPATH/pkg/mod
). The file tree in the mod cache is read-only (for good reasons) so while changing it works, it is not the way to go.I could create a local commit to the library or create a new debug branch in my local copy of the library. Then I insert my debug code and commit it. Then I point my main program's
go.mod
file at the new commit/branch, adding areplace
along the way to use my local copy. Then when I am done debugging I roll everything back. This works but is very annoying for just a temporary print statement here and there.I also tried temporarily vendoring my main program but then it would not build at all. Concretely I use GLFW which contains C files but they are not copied over by
go mod vendor
so the library does not compile anymore. Then even if vendoring would work correctly, I still consider this too much work for debugging.What did you expect to see?
A simple way to locally debug my dependencies without changing file access rights, using git or vendoring. In GOPATH mode this was the default behavior and made things simple while debugging. Of course I see the benefits of Go modules and want to use them but this common use case seems hard to do now.
What did you see instead?
Go modules seemingly complicating the debugging process.
The text was updated successfully, but these errors were encountered: