Windows7 (x86) 配置Go语言IDE开发环境, 编译loraserver手记

32位Windows7 配置Go语言IDE开发环境, 编译loraserver,解决代码中的错误

1. 安装vscode,安装依赖

(0) 安装vscode

作者: Go_小易
博文: Go 语言 IDE 之 VSCode 配置使用 (http://www.cnblogs.com/yangxiaoyi/p/9692369.html)

(1) golang.org/x/net

由于golang、googleapis等网站被墙,因此很多依赖包在下载的时候会有问题。为了使包的导入方式不变,我们需要在src目录下面构造目录结构
$ mkdir -p $GOPATH/src/golang.org/x/
$ cd $GOPATH/src/golang.org/x/
$ git clone https://github.com/golang/net.git
$ go install net
--------------------- 
作者:冰_封 
原文:https://blog.csdn.net/xie1xiao1jun/article/details/79421136 
golang在github上的托管 (官网)

https://github.com/golang

(2) tools

github.com> git clone https://github.com/golang/tools.git

(3) lint

github.com> git clone https://github.com/golang/lint.git
go install github.com/golang/lint/golint

(4) derekparker/delve/cmd/dlv

src\github.com> git clone https://github.com/derekparker/delve.git
go install github.com/derekparker/delve/cmd/dlv
# github.com/derekparker/delve/pkg/proc
derekparker\delve\pkg\proc\disasm.go:12:14: undefined: archInst 

求助于度娘、必应,必应给出了一条官网的Issue: https://github.com/derekparker/delve/issues/20,delve不支持x86 (32位)

因此,在32位widnows上,是没法使用vscode调试Go代码的!!! [注: 可以编译,编译不依赖vscode环境,在命令行下输入 go build 命令即可]


2. 安装编译 loraserver所需要的依赖

(1) 下载lorawan, loraserver

go get github.com/brocaar/lorawan
go get github.com/brocaar/loraserver

(2) LiteIDE编译,逐个解决报告的依赖

src\github.com>git clone https://github.com/kisielk/errcheck.git
go install -v github.com/kisielk/errcheck

go get -u github.com/NickBall/go-aes-key-wrap

go get -u github.com/grpc-ecosystem/go-grpc-middleware/tags
go get -u github.com/jmoiron/sqlx
go get -u github.com/grpc-ecosystem/go-grpc-middleware/tags

src\golang.org\x> git clone https://github.com/golang/net.git
go install -v net
go install -v golang.org/x/tools/cmd/guru
go get -u -v github.com/lib/pq
go get -u -v github.com/eclipse/paho.mqtt.golang
go get -u -v github.com/garyburd/redigo/redis
go get -u -v github.com/gofrs/uuid
go get -u -v github.com/golang/protobuf/jsonpb
go get -u -v github.com/rubenv/sql-migrate
go get -u -v github.com/sirupsen/logrus
go get -u -v github.com/spf13/cobra
go get -u -v github.com/spf13/viper

(3) grpc

参考文章: golang安装gRpc (https://studygolang.com/articles/14035?fr=sidebar)

google.golang.org> git clone https://github.com/grpc/grpc-go.git
mv grpc-no grpc    ##
golang.org/x>      git clone https://github.com/golang/net.git
golang.org/x>      git clone https://github.com/golang/text.git
google.golang.org> git clone https://github.com/google/go-genproto.git
mv go-genproto 	genproto      ##
go get  -u -v github.com/golang/protobuf/{proto,protoc-gen-go}
go install -v google.golang.org/genproto/googleapis/api/annotations
go install -v google.golang.org/grpc

(4) crypt

golang.org/x>  git clone https://github.com/golang/crypto.git
go install -v 	golang.org/x/crypto

(5) google-cloud-go

golang.org\x>	git clone https://github.com/golang/exp.git
go install -v 	golang.org/x/exp/rand
mkdir gonum.org
src\gonum.org>	git clone https://github.com/gonum/gonum.git
src\gonum.org>	mkdir v1
src\gonum.org>	mv gonum v1
go install -v 	gonum.org/v1/gonum/graph

src\github.com>	git clone https://github.com/googleapis/googleapis.git
go install github.com/googleapis/gax-go

src\go.opencensus.io>	git clone https://github.com/census-instrumentation/opencensus-go.git
src\go.opencensus.io>	mv opencensus-go\* .
go install -v 	go.opencensus.io/plugin/ocgrpc
go install -v 	go.opencensus.io/stats
go install -v 	go.opencensus.io/tag

golang.org\x>	git clone https://github.com/golang/sync.git
go install -v 	golang.org/x/sync/errgroup
go install -v 	golang.org/x/sync/semaphore

cloud.google.com> 	git clone https://github.com/google/go-cloud.git
cloud.google.com> 	git clone https://github.com/GoogleCloudPlatform/google-cloud-go.git
cloud.google.com> 	mv google-cloud-go  go	##
go install -v 		cloud.google.com/go/pubsub

(6) google.golang.org/api

golang.org/x>	git clone https://github.com/golang/oauth2.git
go install -v	golang.org/x/oauth2

src\google.golang.org> git clone https://github.com/googleapis/google-api-go-client.git
src\google.golang.org>	mv  google-api-go-client api
go install -v  google.golang.org/api/iterator
go install -v 	google.golang.org/api/option
go install -v 	google.golang.org/api/support/bundler
go install -v	google.golang.org/api/transport

花了大半天时间,终于做完上述工作,编译时不再报告包依赖错误。


3. 编译 brocaar loraserver (LiteIDE编译, 或vscode下终端命令行按下述步骤执行命令)

参考: loraserver 源码解析 (一) 构建 (https://blog.csdn.net/wangjunsheng/article/details/80830835?utm_source=blogxgwz4)
作者: 乃不知有汉

(1) 修正代码错误 (version = tag: v2.3.0 )

loraserver\internal\downlink\multicast\min_gw_set.go
第48行
for _, e := rangedst.Edges()

** 修改为 **
for _, e := range graph.EdgesOf(dst.Edges())

第173行
if len(gwNodes) != 0 {
	...
}

** 修改为 **
if len(graph.NodesOf(gwNodes)) != 0 {

}

(2) 生成migrations

运行 go generate cmd/loraserver/main.go
会借助 go-bindata 生成 internal/migrations/migrations_gen.go

(3) 生成loraserver.exe

cd /loraserver/cmd/loraserver
go build -v
然后,我们看到生成了
loraserver.exe

你可能感兴趣的:(IoT,Windows,知识&技巧,IDE,IoT,loraserver,vscode,golang,LiteIDE)