I am trying to build the package github.com/go-delve/delve/cmd/dlv@2f13672765fe and have the resulting executable named dlv-dap.
Under older versions of go (pre 1.16) I was able to accomplish this by running the following commands.
go get github.com/go-delve/delve/cmd/dlv@2f13672765fego build -o dlv-dap github.com/go-delve/delve/cmd/dlv@2f13672765fe
Under v1.17 this no longer works, instead the command go get github.com/go-delve/delve/cmd/dlv@2f13672765fe throws the following error
go: go.mod file not found in current directory or any parent directory. 'go get' is no longer supported outside a module. To build and install a command, use 'go install' with a version, like 'go install example.com/cmd@latest' For more information, see https://golang.org/doc/go-get-install-deprecation or run 'go help get' or 'go help install'.
Reading the information link provided in the error it seems there is no longer a way to download/build a golang package with a customized name (e.g. -o my_custom_named_executable).
Is my understanding correct or is there another way to accomplish this?
CodePudding user response:
Here are 2 solutions to do what you want:
First solution: go install
This will install the dlv executable to your $GOPATH/bin directory.
go install github.com/go-delve/delve/cmd/dlv@2f13672765fe
Second solution: install from source:
git clone [email protected]:go-delve/delve.git
cd delve
git checkout 2f13672765fe
go build -o dlv ./cmd/dlv
This will build dlv executable to the root of the project.
Run Delve DAP
Use dlv dap subcommand, dlv-dap is just an alias to that.
