└── bin ├── detect ├── release └── compile /bin/detect: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Go build env" 3 | exit 0 4 | -------------------------------------------------------------------------------- /bin/release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | BUILD_DIR="$1" 6 | 7 | cat << EOF 8 | --- 9 | EOF 10 | -------------------------------------------------------------------------------- /bin/compile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | GO_VERSION="1.6" 6 | GO_SRC_SHA="5470eac05d273c74ff8bac7bef5bad0b5abbd1c4052efbdbc8db45332e836b0b" 7 | 8 | BUILD_DIR="${1-/app/build}" 9 | CACHE_DIR="${2-/app/cache}" 10 | ENV_DIR="${3-/app/env}" 11 | 12 | GO_SRC_URL="https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" 13 | GOS_DIR="${BUILD_DIR}/_go" 14 | GO_TAR="${CACHE_DIR}/go${GO_VERSION}.linux-amd64.tar.gz" 15 | GO_DST="${GOS_DIR}/${GO_VERSION}" 16 | GO_TMP_DST="${CACHE_DIR}/go-env" 17 | 18 | 19 | if [ ! -f "${GO_TAR}" ]; then 20 | rm -f "${GO_TAR}" 21 | curl -L "${GO_SRC_URL}" > "${GO_TAR}" 22 | echo "${GO_SRC_SHA} ${GO_TAR}" | sha256sum --check --status - 23 | fi 24 | 25 | mkdir -p "${GOS_DIR}" 26 | mkdir -p "${GO_TMP_DST}" 27 | tar -C "${GO_TMP_DST}" -xzf "${GO_TAR}" 28 | mv "${GO_TMP_DST}/go" "${GO_DST}" 29 | rm -rf "${GO_TMP_DST}" 30 | 31 | mkdir -p "${BUILD_DIR}/.profile.d" 32 | GO_ENV_VAR="$(echo "GO_${GO_VERSION}" | sed 's|[.]||g')" 33 | echo "export ${GO_ENV_VAR}=/app/_go/${GO_VERSION}" > "${BUILD_DIR}/.profile.d/go${GO_VERSION}.sh" 34 | --------------------------------------------------------------------------------