Rather exotic use-case - if you have an executable and forgot where it was built from, import-path
tells you its import path:
import-path() {
[[ -z "$1" ]] && { echo "usage: import-path EXECUTABLE" >&2; return 1; }
go tool objdump -s main.main "$(which $1)" |
grep -E '^TEXT main.main' | cut -d' ' -f3 |
sed -e 's/.*\/src\/\(.*\)\/[^\/]*/\1/'
}
$ import-path godoc
golang.org/x/tools/cmd/godoc