ERROR
version 0.3.3
1
2
3
4
5
6
7
8
9
10
11
| go: finding module for package github.com/bilibili/kratos/pkg/time
go: found github.com/bilibili/kratos/pkg/log in github.com/bilibili/kratos v0.5.0
go: found github.com/BurntSushi/toml in github.com/BurntSushi/toml v0.3.1
go: found google.golang.org/grpc/resolver in google.golang.org/grpc v1.31.0
go: found golang.org/x/sync/errgroup in golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
go: found github.com/smartystreets/goconvey/convey in github.com/smartystreets/goconvey v1.6.4
go: found gopkg.in/h2non/gock.v1 in gopkg.in/h2non/gock.v1 v1.0.15
go: github.com/bilibili/discovery/cmd/discovery imports
github.com/bilibili/kratos/pkg/log: github.com/bilibili/kratos@v0.5.0: parsing go.mod:
module declares its path as: github.com/go-kratos/kratos
but was required as: github.com/bilibili/kratos
|
- 原因
- kratos 历史遗留原因 从 bilibili 一直 go-kratos 仓库
- 解决方法
-go.mod 文件中制定版本
1
| github.com/bilibili/kratos v0.3.3
|
运行不报错,也不成功
- 原因
- discovery 配置不成功
- discovery 使用字段(env、node…)
- 解决方法
访问其他节点超时
- 原因
- 从本地机器代理、开发工具代理设置
- discovery 的地址 与其他节点不再同一个 discovery
- 访问节点没有启动
- AppId 错误
- 访问节点 grpc 地址错误
- 解决方法
- 查看访问节点是否在 discovery 中
- 本地机器 ping 访问节点 grpc 地址
- 检查开发工具代理设置
- 查看访问 AppId 是否和 discovery 一致
运行成功没有打印监听端口
1
2
3
| log.Init(nil) // debug flag: log.dir={path}
defer log.Close()
log.Info("user-location start")
|
- 原因
- 解决方法
- 初始化 log 时只需要给
log.Init()
不为 nil
1
2
3
| log.Init(&log.Config{Stdout: true}) // debug flag: log.dir={path}
defer log.Close()
log.Info("user-location start")
|
启动环境变量错误
1
2
3
4
5
| LOG_V=1;
LOG_STDOUT=true;
APP_ID=userlocation;
DISCOVERY_NODES=172.12.14.82:7171;
ZONE=sz001;DEPLOY_ENV=dev;
|
0.7.0 *types.Empty
types.Empty
导致依赖注入生成文件失败
1
| types "github.com/gogo/protobuf/types"
|
Goland Protocl
搜索:Protocol Buffers
、加上自己的项目目录即可
参考链接
proto 设置引导路径
file:///opt/gopath/pkg/mod/github.com/gogo/googleapis@v1.4.0
file:///opt/gopath/pkg/mod/github.com/gogo/protobuf@v1.3.1
protoc 版本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| # git.huoys.com/middle-end/kratos/pkg/net/rpc/warden/balancer/p2c
/opt/gopath/pkg/mod/git.huoys.com/middle-end/kratos@v0.7.0/pkg/net/rpc/warden/balancer/p2c/p2c.go:34:5: cannot use &p2cPickerBuilder literal (type *p2cPickerBuilder) as type base.PickerBuilder in assignment:
*p2cPickerBuilder does not implement base.PickerBuilder (wrong type for Build method)
have Build(map[resolver.Address]balancer.SubConn) balancer.Picker
want Build(base.PickerBuildInfo) balancer.Picker
/opt/gopath/pkg/mod/git.huoys.com/middle-end/kratos@v0.7.0/pkg/net/rpc/warden/balancer/p2c/p2c.go:35:5: cannot use &p2cPicker literal (type *p2cPicker) as type balancer.Picker in assignment:
*p2cPicker does not implement balancer.Picker (wrong type for Pick method)
have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error)
want Pick(balancer.PickInfo) (balancer.PickResult, error)
/opt/gopath/pkg/mod/git.huoys.com/middle-end/kratos@v0.7.0/pkg/net/rpc/warden/balancer/p2c/p2c.go:42:32: not enough arguments in call to base.NewBalancerBuilder
have (string, *p2cPickerBuilder)
want (string, base.PickerBuilder, base.Config)
/opt/gopath/pkg/mod/git.huoys.com/middle-end/kratos@v0.7.0/pkg/net/rpc/warden/balancer/p2c/p2c.go:144:2: cannot use p (type *p2cPicker) as type balancer.Picker in return argument:
*p2cPicker does not implement balancer.Picker (wrong type for Pick method)
have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error)
want Pick(balancer.PickInfo) (balancer.PickResult, error)
|
- 解决方法
设置引入包版本,kratos 0.7.0 版本内部版本
1
2
3
4
5
6
7
8
9
10
11
12
|
go 1.14
require (
git.huoys.com/middle-end/kratos v0.7.0
github.com/BurntSushi/toml v0.3.1
github.com/gogo/googleapis v1.4.0
github.com/gogo/protobuf v1.3.1
github.com/google/wire v0.4.0
google.golang.org/grpc v1.29.1
)
|