github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/build-goplugin.sh (about)

     1  #!/bin/bash
     2  
     3  pkg=$1
     4  codeDIR=$2
     5  if [ -z "$pkg" ]; then
     6      echo "error: package name is null"
     7      echo "usage: "
     8      echo "     bash build-goplugin.sh pkg codeDir"
     9      exit 1
    10  fi 
    11  
    12  if [ -z "$codeDIR" ]; then
    13      echo "error: plugin code dir is null"
    14      echo "usage: "
    15      echo "     bash build-goplugin.sh pkg codeDir"
    16      exit 1
    17  fi
    18  echo "Building $pkg($codeDIR)"
    19  
    20  go mod tidy
    21  go mod vendor
    22  
    23  tee -a go.mod <<EOF
    24  require $pkg v0.0.0-00010101000000-000000000000
    25  replace $pkg => $codeDIR
    26  EOF
    27  
    28  go build -buildmode=plugin -mod=readonly $pkg
    29  
    30  git checkout -- go.mod