我正在尝试使用 gRPC 编写一个服务,当我导入 protobuff 文件时,出现错误。我尝试删除 go 路径中的所有模块并重新初始化 go 模块build _/Users/tibinlukose/cart-service/pb: cannot find module for path _/Users/tibinlukose/cart-service/pb代码package mainimport ( pbcart "../pb/" "log" "fmt" "google.golang.org/grpc" "net")var ( port = 1000;)type CartServiceServer struct {}func main() { log.SetFlags(log.LstdFlags | log.Lshortfile) fmt.Println("Server Starting ..") lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", 10000)) if err != nil { log.Fatal("unable to listen on the port") } serverOptions := []grpc.ServerOption{} grpcServer := grpc.NewServer(serverOptions...) srv := &CartServiceServer{} pbcart.RegisterCartServiceServer(grpcServer, srv)}环境GOCACHE="/Users/tibinlukose/Library/Caches/go-build"GOENV="/Users/tibinlukose/Library/Application Support/go/env"GOPATH="/Users/tibinlukose/go"GOROOT="/usr/local/Cellar/go/1.13.4/libexec"GOTOOLDIR="/usr/local/Cellar/go/1.13.4/libexec/pkg/tool/darwin_amd64"GOMOD="/Users/tibinlukose/cart-service/server/go.mod"仓库https://github.com/zycon/cart-service
- 1 回答
- 0 关注
- 135 浏览
添加回答
举报
0/150
提交
取消