You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tried to install delve to a different binary output than the default.
go install -o $GOBIN/dlv-dap github.com/go-delve/delve/cmd/dlv@master
What did you expect to see?
I expected to see go install respect the -o build flag that works with go build.
What did you see instead?
flag provided but not defined: -o
On closer inspection I see there's a distinction that is counterintuitive. The go build command supports "build flags" and other flags, where -o is one of those other flags and not a "build flag" even though -o is a flag of the "build" command.
$ go help install
usage: go install [build flags] [packages]
For more about the build flags, see 'go help build'.
$ go help build
usage: go build [-o output] [build flags] [packages]
The -o flag forces build to write the resulting executable or object
to the named output file or directory, instead of the default behavior
Installing to other filenames would be convenient and useful for go install for the same reasons it is convenient and useful for go build. Sometimes the output file needs to be different. In my specific example I'm attempting to install delve in the same way that the vscode-go extension installs delve, with the master branch version of delve installed at $GOBIN/dlv-dap and the latest version installed at $GOBIN/dlv.
Of course, it is possible to install using go build manually in the longer form, and so this isn't a huge deal: