need to debug a dependency locally

onqtam :

I need to debug a project with a few prints to stdout: https://github.com/protolambda/zcli

and it has a dependency on this: https://github.com/protolambda/zrnt

The piece of code I need to debug is inside of zrnt.

I've installed the zcli tool locally with go get -u -tags preset_minimal github.com/protolambda/zcli and I can see the code for zrnt in both ~/go/pkg/mod/github.com and ~/go/src/github.com - so my question is: Where should I edit and what command should I use to rebuild it?

And is there any easy way of removing all local changes from a package's source when I'm done - something like git checkout .?

I'm totally new to Go and it would be desirable if I could avoid learning about the package management for a few hours...

Kamol Hasan :

One way to do this, use Go modules.

  1. Menually active module mode:
$ export GO111MODULE=on 
  1. Initialize a new module:
$ go mod init github.com/protolambda/zcli

go: creating new go.mod: module github.com/protolambda/zcli
  1. Now go to the project directory ($cd github.com/protolambda/zcli) and run:
$ go mod tidy
$ go mod vendor
  1. Running those commands will create a vendor folder with all the dependencies. Edit them the way you like & use the following command to build your project.
$ go build ./...
  1. Use $ go mod vendor to reset the main module's vendor directory.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related