Open deepakjois opened 8 years ago
This is a reasonable request, but it's going to be a little tricky at this time.
First, there might be ambiguities, where it's unclear if a binary named foo
is coming from import path bar/cmd/foo
or baz/cmd/foo
. Here's a real world example:
go-diff
STALE: github.com/daviddengcn/go-diff (build ID mismatch)
STALE: sourcegraph.com/sourcegraph/go-diff/cmd/go-diff (build ID mismatch)
That's really the main concern right now. I have an idea for how to potentially get around this. When/if #6 is resolved, this might become more viable. I'll leave this open and add a "thinking" label for now.
Meanwhile, someone on reddit shared the following unix-y way you can achieve this goal:
binstale | grep 'stale:' | cut -d " " -f2 | xargs go get -u
You can try that, maybe even make an alias for it if you do it often.
Could the update option simply skip all ambiguous cases?
@christophberger Yes, that's a possible workaround.
However, instead of investing into workarounds, I think I'd rather resolve #6 and this can be solved more properly. Until then, the grep-cut-xargs solution should be okay.
Good point. Waiting for #6... :)
I discovered that Go binaries still include the source path that they were compiled from. This Reddit comment pointed me to this shell function which uses go tool objdump
and extracts the source path from the objdump output line that starts with TEXT main.main
.
This looks like a sure-fire way of unambiguously determining the source project of a binary.
@christophberger Thanks for sharing the info. I know they currently do.
I already have a prototype of that working at https://godoc.org/github.com/shurcooL/play/200/cmd/importpathof (source code).
It's been on my plans/TODO to take advantage of that:
However, using that information would mean a massive re-architecture of a huge portion of binstale
code. Before doing that, I wanted to ask on the Go mailing list for the opinion of the Go team whether or not they expect such import path information is expected to always continue to be there in the future versions of Go, or if they think it's temporary and I should not rely on it.
I just tried binstale, and the next thing I wanted was to update all the stale binaries. Maybe you could provide a flag (
-u
perhaps…) which can update the stale binaries, by invokinggo get -u