Skip to content

Commit

Permalink
Support examples for go module
Browse files Browse the repository at this point in the history
  • Loading branch information
BewareMyPower committed Oct 21, 2019
1 parent c714cd7 commit f14bc14
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
24 changes: 24 additions & 0 deletions golang/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,27 @@ rm -rf ./examples/src
mkdir -p ./gopath/src/qbus
cp libQBus_go.so ./gopath/src/qbus
cp qbus.go ./gopath/src/qbus

while true; do
echo -n "Use go module for examples? [Y/n]: "
read ANSWER

if [[ $ANSWER =~ ^[yYnN] ]]; then
if [[ ${ANSWER:0:1} = [yY] ]]; then
export GO111MODULE=on
mkdir -p examples/qbus
cp libQBus_go.so ./examples/qbus
cp qbus.go ./examples/qbus

cd examples && go mod init examples
echo "
require qbus v1.0.0
replace qbus => ./qbus" >> go.mod
cd qbus && go mod init qbus
fi
break
else
echo "[ERROR] invalid input: $ANSWER!"
fi
done
8 changes: 4 additions & 4 deletions golang/examples/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
echo "1. 先将安装包解压缩后的gopath目录加入GOPATH;"
echo "2. 要运行编译后的文件,请手动将libQBus_go.so路径加入LD_LIBRARY_PATH,比如"
echo ' LD_LIBRARY_PATH=$PWD/../gopath/src/qbus ./consumer'
export GOPATH="$PWD/../gopath"
echo '1. 如果不使用go.mod,请先将安装包解压缩后的gopath目录加入GOPATH,比如:'
echo ' export GOPATH=$PWD/../gopath'
echo '2. 要运行编译后的文件,请手动将libQbus.so的路径加入LD_LIBRARY_PATH,比如:'
echo ' export LD_LIBRARY_PATH=$PWD/../gopath/src/qbus:$LD_LIBRARY_PATH'

TARGETS=( \
consumer \
Expand Down
2 changes: 2 additions & 0 deletions golang/examples/clean.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!/bin/bash
rm -v consumer producer consumer_commit_in_goroutine consume_pause_resume
rm -rv qbus
rm -rv go.mod

0 comments on commit f14bc14

Please sign in to comment.