另外整个编译过程绝对还是会出现包被墙的情况,9102年了,GO 1.11 有个 moudule 可以很方便的处理这些情况。大家可以处理下 go.mod 的文件,具体在我另一篇笔记中有记录,The Things Network LoRaWAN Stack V3 学习笔记 1.2 源码编译。
git clone https://github.com/brocaar/lora-gateway-bridge
cd lora-gateway-bridge/
make dev-requirements
make build
./build/lora-gateway-bridge configfile > lora-gateway-bridge.toml
git clone https://github.com/brocaar/loraserver
cd loraserver/
make dev-requirements
make build
我们在 make build 时可能会遇到 缺少 go-bindata 的问题:
# make build
Generating static files
internal/migrations/migrations.go:1: running "go-bindata": exec: "go-bindata": executable file not found in $PATH
make: *** [statics] Error 1
go get -u github.com/jteeuwen/go-bindata/...
安装完了之后可能会找不到go-bindata,提示错误:“-bash: /usr/bin/go-bindata: No such file or directory”。原因在于由于没有定义GOBIN目录,它会自动安装到GOPATH\bin目录下。去那里找找。
找到之后,在PATH里面追加go-bindata的路径。
#通过命令行加入GOBIN的PATH
export PATH=$PATH:$GOPATH/bin
AS 需要 Node.js 和 Go protocol buffer。
git clone https://github.com/brocaar/lora-app-server
cd lora-app-server/
make dev-requirements ui-requirements
make clean
make build
如果调整了 .proto 文件,那就需要 make api 处理下,否则可以跳过这一步。当前的 api 的目录下
make api 时遇到了问题,没有找到 protoc 命令。
# make api
Generating API code from .proto files
go: downloading github.com/golang/appengine v1.6.0
go: extracting github.com/golang/appengine v1.6.0
gen.sh: line 10: protoc: command not found
gen.sh: line 28: protoc: command not found
gen.sh: line 46: protoc: command not found
安装之:
PROTOC_ZIP=protoc-3.7.1-linux-x86_64.zip
curl -OL https://github.com/google/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
rm -f $PROTOC_ZIP