go get

Run the Go vendoring process in reverse

by release-engineering

v1.0.0 (see all)License:GPL-3.0
go get


Go Report Card GoDoc Build Status Coverage Status

This command inspects a Go source tree with vendored packages and attempts to work out the versions of the packages which are vendored, as well as the version of top-level package itself.

It does this by comparing file hashes of the packages with those from the upstream repositories.

If no semantic version tag matches but a commit is found that matches, a pseudo-version is generated.


go get


retrodep: help requested
usage: retrodep [OPTION]... PATH
        show debugging output
        show vendored dependencies (default true)
  -diff string
        compare with upstream ref (implies -deps=false)
  -exclude-from exclusions
        ignore directory entries matching globs in exclusions
        print help
  -importpath string
        top-level import path
  -o string
        output format, one of: go-template=...
        only show the top-level import path
  -template string
        go template to use for output with Reference fields (deprecated)
  -x    exit on the first failure

In many cases retrodep can work out the import path for the top-level project. In those cases, simply supply the directory name to examine:

$ retrodep src

If it cannot determine the import path, provide it with -importpath:

$ retrodep -importpath src

By default both the top-level project and its vendored dependencies are examined. To ignore vendored dependencies supply -deps=false:

$ retrodep -deps=false -importpath src

If there are additional local files not expected to be part of the upstream version they can be excluded:

$ cat exclusions
$ ls -d src/Dockerfile src/.git
$ retrodep -exclude-from=exclusions src

Exit code

Exit codeReason
0all versions were found (or -diff: no changes)
1any error was encountered other than those below
2a version was missing
3import path needed but not supplied
4no Go source code was found at the provided path
5in -diff mode, changes were found

Example output

$ retrodep $GOPATH/src/

In this example,

  • is the top-level package, and the upstream semantic version tag v2.7.1 matches
  • etc are vendored dependencies of distribution
  •,,, and all had matches with upstream semantic version tags
  • matched a commit from which tag v1.0.2 was reachable (note: v1.0.2, not v1.0.3 -- see below)
  • matched a commit from which there were no reachable semantic version tags


The pseudo-versions generated by this tool are:

  • v0.0.0-0.yyyyddmmhhmmss-abcdefabcdef (commit with no relative tag)
  • vX.Y.Z-pre.0.yyyyddmmhhmmss-abcdefabcdef (commit after semver vX.Y.Z-pre)
  • vX.Y.(Z+1)-0.yyyyddmmhhmmss-abcdefabcdef (commit after semver vX.Y.Z)
  • tag-1.yyyyddmmhhmmss-abcdefabcdef (commit after tag)

Diff mode

When supplying the -diff option, retrodep compares with a specific version only, and outputs the differences (in unified diff format) between the local files and the upstream files.

To compare source code in src with a known upstream version of a package, use it like this:

$ retrodep -diff v1.2.0 src

No output (and a zero exit code) means the source code in src matches the upstream version v1.2.0 of Otherwise, the differences in src compared to the upstream version are shown in unified diff format, and the exit code is 5.

Files in src that are not in the upstream version are presented as diffs compared with "/dev/null". Files in the upstream version but not in src are ignored.


The vendor directory is assumed to be complete.

Original source code is assumed to be available.

Only git and repositories are currently supported, and working 'git' and 'hg' executables are assumed to be available.

Non-Go code is not considered, e.g. binary-only packages, or CGo.

Commits with additional files (e.g. *_linux.go) are identified as matching when they should not.

Packages vendored from forks will not have matching commits.

Files marked as "export-subst" in .gitattributes files in the vendored copy are ignored.

GitHub Stars



2yrs ago








1yr ago
1yr ago
1yr ago
1yr ago
No alternatives found
No tutorials found
Add a tutorial