-
-
Save Stebalien/7bfd1ea07f81c1fbbe9eadac4faeccd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export IPFS_GATEWAY="${IPFS_GATEWAY:-http://127.0.0.1:8080}" | |
CACHE_DIR="$(go env GOPATH)/pkg/mod/cache" | |
basepath() { | |
echo "${1##${CACHE_DIR}/download/}" | |
} | |
case "$1" in | |
ipfs-lock) | |
export GO111MODULE=on | |
temp="$(mktemp -d "$CACHE_DIR/.tmpXXXXXXXXX")" | |
trap 'rm -rf "$temp"' 0 | |
go mod download -json > "$temp/info.json" | |
jq -r '"VERSION=\(.Version | @sh) INFO=\(.Info | @sh) GOMOD=\(.GoMod | @sh) ZIP=\(.Zip | @sh)"' < "$temp/info.json" \ | |
| while read line; do | |
eval "$line" | |
echo $INFO | |
base="$(dirname "${temp}/bundle/$(basepath "$INFO")")" | |
mkdir -p "$base" | |
ln -t "$base" "$INFO" "$GOMOD" "$ZIP" | |
echo "$VERSION" > "$base/list" | |
done | |
HASH="$(ipfs add -Qr "$temp/bundle")" | |
echo "/ipfs/$HASH" > deps.ipfs | |
;; | |
*) | |
if [[ -e "deps.ipfs" ]]; then | |
path="$(< deps.ipfs)" | |
export GOPROXY="${IPFS_GATEWAY}$path" | |
export GO111MODULE=on | |
fi | |
exec go "${@}" | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment