golang go-plugins http请求错误

1.错误1

go build github.com/lucas-clemente/quic-go/internal/qtls: build constraints exclude all Go files in C:\Users\admin\go\pkg\mod\github.com\lucas-clemente\quic-go@v0.22.0\internal\qtls FAILgomicro-demo2 [build failed]

解决方法 go.mod中的quic-go注释掉
// github.com/lucas-clemente/quic-go v0.22.0 // indirect
2.错误2
cannot use client.ContentType("application/json") (value of type client.Option) as client.Option value in argument to phttp.NewClient

golang go-plugins http请求错误
文章图片

解决方法 go-micro版本不一致,修改为一致
"github.com/micro/go-micro/v2/client" "github.com/micro/go-micro/v2/client/selector" "github.com/micro/go-micro/v2/registry" phttp "github.com/micro/go-plugins/client/http/v2" "github.com/micro/go-plugins/registry/consul/v2"

3.错误3 请求报500错误
{"id":"go.micro.client","code":500,"detail":"none available","status":"Internal Server Error"}

解决方法
server := web.NewService( web.Name("USER_SERVICE"), web.Address(":8089"), web.Handler(r), web.Registry(consulReg), web.Metadata(map[string]string{"protocol" : "http"}),//添加web 元信息 web.Registry(consulReg), web.RegisterInterval(time.Second*15), )

错误4 由于我本地使用的golang版本换成了1.14版本,原来的dlv版本是1.15的
version of Go is too old for this version of Delve (minimum supported version 1.15, suppress this error with --check-go-version=false)

解决方法
删除dlv,重新安装
参考 https://studygolang.com/artic...
# cd $GOPATH/src/ # git clone https://github.com/derekparker/delve.git # cd delve/cmd/dlv/ # go build # go install

错误5 proto生成的pb.micro.go文件中的server版本和go-micro中server的不一致
golang go-plugins http请求错误
文章图片

golang go-plugins http请求错误
文章图片

解决方法
删除gopath下的
golang go-plugins http请求错误
文章图片

然后重新下载,重新生成pb.go和pb.micro.go文件
go get github.com/micro/micro/v2/cmd/protoc-gen-micro@master
错误6
go run main.go

报错
# github.com/coreos/etcd/clientv3/balancer/resolver/endpoint ..\..\..\go\pkg\mod\github.com\coreos\etcd@v3.3.18+incompatible\clientv3\balancer\resolver\endpoint\endpoint.go:114:78: undefined: resolver.BuildOption ..\..\..\go\pkg\mod\github.com\coreos\etcd@v3.3.18+incompatible\clientv3\balancer\resolver\endpoint\endpoint.go:182:31: undefined: resolver.ResolveNowOption # github.com/coreos/etcd/clientv3/balancer/picker ..\..\..\go\pkg\mod\github.com\coreos\etcd@v3.3.18+incompatible\clientv3\balancer\picker\err.go:37:44: undefined: balancer.PickOptions ..\..\..\go\pkg\mod\github.com\coreos\etcd@v3.3.18+incompatible\clientv3\balancer\picker\roundrobin_balanced.go:55:54: undefined: balancer.PickOptions

解决方法
go.mod中替换grpc版本
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0

错误7 pb生成的代码,grpc请求超时错误
2021-07-27 18:09:02.207059 I | prodRes err: {"id":"go.micro.client","code":408,"detail":"context deadline exceeded","status":"Request Timeout"}

【golang go-plugins http请求错误】client默认的超时错误时间是5s
golang go-plugins http请求错误
文章图片

    推荐阅读