Comments (12)
明显有问题 MICRO_REGISRY_ADDRESS
-> MICRO_REGISTRY_ADDRESS
from stack-rpc-tutorials.
但是写错MICRO_REGISRY_ADDRESS这个相当于没有写,会默认使用127.0.0.1,也就相当于是192.168.1.3
from stack-rpc-tutorials.
是user-api->user-srv这一步不通?把代码脱敏放上来看看
from stack-rpc-tutorials.
我想用一个最简单的例子看看有没有我提到的问题但是却出现另外一个问题
我在目录micro_demo创建应用
micro version 1.9.1
- micro new micro_demo/api/user --type api --namespace com.abc
- micro new micro_demo/srv/user --type srv --namespace com.abc
- protoc --proto_path=$GOPATH/src:. --go_out=. --micro_out=. srv/user/proto/user/user.proto
- protoc --proto_path=$GOPATH/src:. --go_out=. --micro_out=. api/user/proto/user/user.proto
- 修改api user里的client 和 handler 的srv user proto引入路径修改成 user "micro_demo/srv/user/proto/user"
- 进入目录运行 api/user 和 srv/user
go run main.go --registry=consul --registry_address=192.168.1.3
srv/user 运行
但是api/user build command-line-arguments: cannot load micro_demo/srv/user/proto/user: cannot find module providing package micro_demo/srv/user/proto/user
from stack-rpc-tutorials.
micro_demo/srv/user/proto/user -> github.com/你的site/micro_demo/srv/....,或其它domain下。参考gopath下的每个公司的包名路径
from stack-rpc-tutorials.
问题依旧在
go 是GOPATH路径
go/src/github.com/mytest/micro_demo/api/user
micro new srv/user api/user 后
protoc 运行完
问题还是srv正常运行api cannot load github.com/mytest/micro_demo/srv/user/proto/user: cannot find module providing package github.com/mytest/micro_demo/srv/user/proto/user
go version go1.12.9 linux/amd64
from stack-rpc-tutorials.
把代码传到你的仓库中,我看看
from stack-rpc-tutorials.
https://github.com/bluedragonflyliu/micro_demo
from stack-rpc-tutorials.
关于第一个有关consul的问题,好像知道表面原因了,是新的micro创建client的方式和以前不一样了
from stack-rpc-tutorials.
micro new 找不到srv/user/proto/user 的问题我又试了一下
- 新建虚机centos7 最新的
- 安上micro 的环境和依赖
- micro new 新建
- 运行protoc --proto_path=.:$GOPATH/src --go_out=. --micro_out=. mytest/api/user/proto/user/user.proto 会提示 github.com/micro/go-micro/api/proto/api.proto: File not found.
- 直接git clone后protoc 通过
- 将 api/user 里client 和 handler 依赖改成现有srv/user/proto/user
- 运行srv/user 正常
- 运行api/user 还是找不到srv/user/proto
go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://goproxy.io"
GOROOT="/usr/local/bin/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/bin/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/go/src/github.com/abc/mytest/srv/user/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build962096667=/tmp/go-build -gno-record-gcc-switches"
from stack-rpc-tutorials.
Emm,我感觉生成proto文件的那一步指令很奇怪。一般我是切到服务proto目录的上级,相当于micro_demo/api/user目录,然后执行命令,命令参考如下:
protoc --proto_path=.:$GOPATH/src --go_out=. --micro_out=. ./proto/user/user.proto
这样生成的文件与引用方式就是很干净的,不清楚为什么要加上mytest这个与项目目录并不相关的目录。
引用大致如下:
import (
"github.com/bluedragonflyliu/micro_demo/micro_demo/api/user/client"
user "github.com/bluedragonflyliu/micro_demo/micro_demo/api/user/proto/user"
"github.com/micro/go-micro"
"github.com/micro/go-micro/util/log"
)
from stack-rpc-tutorials.
是模板中go.mod的问题
from stack-rpc-tutorials.
Related Issues (20)
- K8s示例 HOT 4
- part1 user-srv运行micro --registry=etcd call mu.micro.book.srv.user User.QueryUserByName '{"userName":"micro"}'报错 HOT 5
- part2 运行问题。 HOT 2
- Micro auto generate topic in kafka when run 1 service. HOT 1
- rpc 调用不通,一直报错 HOT 5
- 一点小提议~ HOT 3
- 根据原文件运行part1出现error HOT 3
- 获取Session中的UserId时,空指针异常 HOT 2
- examples/basic-practices/micro-service/stream/file 问题 HOT 5
- 运行part1时提交请求时出错 HOT 9
- model操作数据实现方式不太明白问题 HOT 1
- 第一章演示user protobuf的问题 HOT 1
- micro api handler value 支持的类型 HOT 2
- 【重要】part 1 根据代码库操作报错 HOT 2
- 在part1中最后的curl请求返回为空 HOT 2
- 第七章, 通过网关不能直接访问到 user_web 服务 HOT 1
- 关于micro auth 的问题 HOT 4
- v3出来了。请同步。 HOT 1
- 求更新v3文档,支持 HOT 1
- 大佬们,v2的文档能不能再放出来一下,才刚开始看就没了 --。 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stack-rpc-tutorials.