github.com/koko1123/flow-go-1@v0.29.6/crypto_setup.sh (about)

     1  
     2  #!/bin/bash
     3  
     4  # crypto package 
     5  PKG_NAME="github.com/onflow/flow-go/crypto"
     6  
     7  # go.mod
     8  MOD_FILE="./go.mod"
     9  
    10  # the version of onflow/flow-go/crypto used in the project is read from the go.mod file
    11  if [ -f "${MOD_FILE}" ]
    12  then
    13      # extract the imported version
    14      VERSION="$(go list -f '{{.Version}}' -m ${PKG_NAME})"
    15      # go get the package
    16      go get "${PKG_NAME}@${VERSION}" || { echo "go get the package failed"; exit 1; }
    17      # using the right version, get the package directory path
    18      PKG_DIR="$(go env GOPATH)/pkg/mod/${PKG_NAME}@${VERSION}"
    19  else 
    20     { echo "couldn't find go.mod file - make sure the script is in the project root directory"; exit 1; }
    21  fi
    22  
    23  # grant permissions if not existant
    24  if [[ ! -r ${PKG_DIR}  || ! -w ${PKG_DIR} || ! -x ${PKG_DIR} ]]; then
    25     chmod -R 755 "${PKG_DIR}"
    26  fi
    27  
    28  # get into the package directory and set up the external dependencies
    29  (
    30      cd "${PKG_DIR}" || { echo "cd into the GOPATH package folder failed"; exit 1; }
    31      go generate
    32  )