#!/bin/bash echo "# This was generated by ./generate-vendor.sh" > Gopkg.lock echo "# This was generated by ./generate-vendor.sh" > Gopkg.toml while read -r package; do cat >> Gopkg.lock <<-_EOF [[projects]] branch = "master" name = "$package" revision = "$(< "$GOPATH/src/$package/.git/refs/heads/master")" _EOF cat >> Gopkg.toml <<-_EOF [[constraint]] branch = "master" name = "$package" _EOF done < <(sed -n 's/.*"\(golang.org\/x\/[^/]\+\)\/\?.*".*/\1/p' *.go */*.go | sort | uniq)