Skip to content

Commit

Permalink
add script to build go plugin (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyang0 committed Nov 1, 2023
1 parent 5409d51 commit e298668
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ build.yaml
*.rpm
*.deb
*.itr
*.so
default.etcd/*
vendor/*
clean.sh
Expand Down
30 changes: 30 additions & 0 deletions build-goplugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

pkg=$1
codeDIR=$2
if [ -z "$pkg" ]; then
echo "error: package name is null"
echo "usage: "
echo " bash build-goplugin.sh pkg codeDir"
exit 1
fi

if [ -z "$codeDir" ]; then
echo "error: plugin code dir is null"
echo "usage: "
echo " bash build-goplugin.sh pkg codeDir"
exit 1
fi
echo "Building $pkg($codeDIR)"

go mod tidy
go mod vendor

tee -a go.mod <<EOF
require $pkg v0.0.0-00010101000000-000000000000
replace $pkg => $codeDIR
EOF

go build -buildmode=plugin -mod=readonly $pkg

git checkout -- go.mod

0 comments on commit e298668

Please sign in to comment.